bash:意外标记附近的语法错误`('

use*_*083 5 shell-script

我正在尝试并排连接一些文件。

我pr在终端中使用命令。它运行良好,但是当我在 shell 脚本中使用它时,我收到以下错误消息:

syntax error near unexpected token `('
Run Code Online (Sandbox Code Playgroud)

这是脚本:

#!/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"
Run Code Online (Sandbox Code Playgroud)

phe*_*mer 12

在命令行上,您的 shell 是 bash。在您的脚本中,您使用/bin/sh. /bin/sh显然在您的系统上不是 bash,并且<()语法显然不存在于任何 shell/bin/sh中。

将shebang(#!/bin/sh部分)更改为#!/bin/bash.