What does the syntax "|&" mean in shell language?

Viewed 5534

Recently, I am installing the PC^2 on my Ubuntu14.04LTS to make up our university's ACM-ICPC Contest environment. But when I run the shell file "pc2server", the system gives me an error alert which is

pc2server: 27: pc2server: Syntax error: "&" unexpected

So I check the file pc2server and find the line 27. I found that the code is

java -d64 -version |& grep -q "Error" && JAVA32=1

I know what syntax | and & means, but what I only just want to know is that what syntax |& means.

2 Answers

Please check answer of John. Here I am adding example for detail understating.

# cat /tmp/test1
cat: /tmp/test1: No such file or directory
# cat /tmp/test1 2> /dev/null | grep "No such file or directory"
# cat /tmp/test1 2> /dev/null |& grep "No such file or directory"
cat: /tmp/test1: No such file or directory

First command returns error as file does not exist (stderr output from command).

Second command do not return any output as stderr of cat command is redirect /dev/null, so grep command do not get stderr of cat command through pipe.

Third command returns output even stderr of cat command is redirected to /dev/null because of pipe with ampersand (|&). It connects stdout and stderr of command1 to command2’s stdin; The implicit redirection of the standard error is performed after any redirections specified by the command.

Related