Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

linux

shell

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.

like image 260
Jason Young Avatar asked Mar 10 '16 13:03

Jason Young


1 Answers

From the bash man page:

Pipelines

A pipeline is a sequence of one or more commands separated by one of the control operators | or |&. The format for a pipeline is:

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

The standard output of command is connected via a pipe to the standard input of command2. This connection is performed before any redirections specified by the command (see REDIRECTION below). If |& is used, the standard error of command is connected to command2’s standard input through the pipe; it is shorthand for 2>&1 |. This implicit redirection of the standard error is performed after any redirections specified by the command.

Check your hash-bang line. Plain sh doesn't support |&.

like image 121
John Kugelman Avatar answered Oct 01 '22 20:10

John Kugelman