spongegrep
is
like grep
, but for whole files: if any line matches the regular
expression given, all lines are output:
% utter foo bar baz | spongegrep foo
foo
bar
baz
% utter foo bar baz | spongegrep quux || echo not found
not found
It also supports negation:
% utter foo bar baz | spongegrep -v quux
foo
bar
baz
% utter foo bar baz | spongegrep -v foo
The benefit over using grep -q foo file && cat file
is that
spongegrep
works on streams and doesn’t need rewinding.
A good use is checking logs or command outputs for error messages, and eating them up if nothing worrisome happened (also nice in crontabs):
% sensors | spongegrep ALARM
NP: Fliehende Stürme—Es gibt mich nicht!