Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "|&" mean in Bash?

Tags:

bash

For example

echo "aaa" |& cat 

What does |& mean here?

Is there a website recommended to look up those? Since most search engines can't support searching special characters.

like image 463
Nan Hua Avatar asked Feb 13 '16 20:02

Nan Hua


2 Answers

From man 1 bash, section Pipelines:

[time [-p]] [ ! ] command [ [|⎪|&] command2 ... ]

If |& is used, command's standard error, in addition to its standard output, is connected to command2's standard input through the pipe

So it is just like the pipe operator |, but piping both standard output and standard error.

like image 189
Oleg Andriyanov Avatar answered Oct 02 '22 10:10

Oleg Andriyanov


This operator pipes both standard output and standard error from the left hand side to the right hand side.

The Bash reference manual has a comprehensive index of all operators where you can look up these operators.

like image 42
lunaryorn Avatar answered Oct 02 '22 10:10

lunaryorn