How do I remove the error output when running a command?
For example, the command:
$ grep -lr "sample" .
In addition to printing files that contain the string "sample", it outputs errors that clutter the output.
grep:<...>: No such file or directory
grep: <...>: No such file or directory
2
1 answers
You can use the built-in command options (according to the help):
$ grep -lsr "sample" .
And you can redirect the error output to nowhere:
$ grep -lr "sample" . 2>/dev/null
3
Author: Nicolas Chabanovsky, 2010-11-26 18:15:49