What does "|&" mean in Bash?

Bash

Bash Problem Overview


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.

Bash Solutions


Solution 1 - Bash

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.

Solution 2 - Bash

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.

Solution 3 - Bash

If ‘|&’ is used, command1’s standard error, in addition to its standard output, is connected to command2’s standard input through the pipe; it is shorthand for 2>&1 |. This implicit redirection of the standard error to the standard output is performed after any redirections specified by the command.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionNan HuaView Question on Stackoverflow
Solution 1 - BashOleg AndriyanovView Answer on Stackoverflow
Solution 2 - BashlunaryornView Answer on Stackoverflow
Solution 3 - BashhonzajdeView Answer on Stackoverflow