firstLine property

String? firstLine

firstLine treats the contents of this String as a cli process and returns the first line written to stdout or stderr as a String. Returns null if no lines are returned.

DCli performs Glob expansion on command arguments. See run for details.

e.g.

'tail -n 10 /var/log/syslog'.firstLine;

See forEach to capture output to stdout and stderr interactively toParagraph to concatenating the return lines into a single string. run to run the application without capturing its output start - to run the process fully detached. toList - returns a lines written to stdout and stderr as a list. lastLine - returns just the last line written to stdout or stderr. parser - returns a parser with the captured output ready to be interpreted as one of several file types.

Implementation

String? get firstLine {
  final lines = toList();

  String? line;
  if (lines.isNotEmpty) {
    line = lines[0];
  }

  return line;
}