I am trying to concatenate some files side by side.
I use the pr
command in the terminal. It works well, but when I use it in a shell script, I get the following error message:
syntax error near unexpected token `('
Here is the script:
#!/bin/sh
myfile1=toto1.dat
myfile1=toto2.dat
file_out=mytoto_out.dat
touch ${file_out}
/usr/bin/pr -mts' ' <( /usr/bin/cut -d' ' -s -f1,2,3,4,5,6,7,8,9,10,11 ${myfile1}) <( /usr/bin/cut -d' ' -s -f8 $myfile2) >>${file_out}
echo ${file_out} " is done"
Best Answer
On the command line, your shell is bash. In your script you're using
/bin/sh
./bin/sh
apparently is not bash on your system, and the<()
syntax is apparently not present in whatever shell/bin/sh
is.Change the shebang (the
#!/bin/sh
part) to#!/bin/bash
.