Issue
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.
Solution
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 for2>&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 |&
.
Answered By - John Kugelman Answer Checked By - Gilberto Lyons (WPSolving Admin)