Skip to content

Instantly share code, notes, and snippets.

@bsutton
Created January 13, 2020 09:38
Show Gist options
  • Select an option

  • Save bsutton/b64c388ac7f5e8948eb84dd9e332a1e5 to your computer and use it in GitHub Desktop.

Select an option

Save bsutton/b64c388ac7f5e8948eb84dd9e332a1e5 to your computer and use it in GitHub Desktop.
grep forEach
#! /usr/bin/env dshell
import 'package:dshell/dshell.dart';
void main() {
'grep error /var/log/syslog'.forEach((line) => print(line));
'grep error /var/log/syslog'.forEach((line) { print('matched $line'); });
'grep error /var/log/syslog'.forEach((line) => print(line), stderr:(line) => print(red(line)));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment