3 ms·
Siblings have already responded to this well, so I'll just add an example: $ ls x ls: cannot access x: No such file or directory $ ls x >/dev/null 2>&1
by akkartik 14y ago
Siblings have already responded to this well, so I'll just add an example:
$ ls x
ls: cannot access x: No such file or directory
$ ls x >/dev/null 2>&1
$ ls x 2>&1 >/dev/null
ls: cannot access x: No such file or directory
The first command shows us trying to list a non-existent file, raising an error. The second sends stderr to stdout before sending stdout to null, suppressing all output. The third sends the error to stdout; any output on stdout would have been suppressed (can you come up with a way to verify this?)
- jrockway 14y agocan you come up with a way to verify this? perl -E 'say q{STDOUT!}; say {*STDERR} q{STDERR!}' (q{...} quoting to avoid ugliness of quotes inside quotes.)