Shortcuts to Redirect/Pipe Both stdout and stderr
05 August 2015
It is frequently seen in shell scripts that both stdout and stderr are redirected or piped to the same destination. Do you know that BASH (and some others) has shortcuts for that? Below is cited from BASH manual.
If
|&
is used, the standard error of COMMAND1 is connected to COMMAND2's standard input through the pipe; it is shorthand for2>&1 |
. This implicit redirection of the standard error is performed after any redirections specified by the command.…
There are two formats for redirecting standard output and standard error:
&>WORDand
>&WORDOf the two forms, the first is preferred. This is semantically equivalent to
>WORD 2>&1…
The format for appending standard output and standard error is:
&>>WORDThis is semantically equivalent to
>>WORD 2>&1
blog comments powered by Disqus