I often see commands like:
command1 |& command2
So what we are doing here is to redirect stderr to stdin, so that both of them will βbecomeβ stdin for the next item in the channel.
Or better described in the Bash Reference Guide β Piping :
A conveyor is a sequence of simple commands separated by one of the control statements | or '| &.
...
If |& , a standard command line error, in addition to its standard output, connects to standard command2s inputs through pipes; this is a shorthand for 2>&1 | . This implicit redirection is a standard error for standard output is executed after any redirection specified by the command.
However, I am wondering: can this syntax be used in all versions of Bash? That is, is it always interchangeable with 2>&1 | ? Can it also be used in any other shell (ksh, csh ...)?
source share