【发布时间】:2015-02-11 12:41:01
【问题描述】:
我是 shell 脚本的新手,我正在尝试从 shell 脚本运行以下命令。
diff <(ssh user@remote_host 'cat remote_file.txt') <(ssh user2@remote_host2 'cat remote_file2.txt')
但出现错误:
./a.sh: syntax error at line 1: `(' unexpected
我通过谷歌搜索尝试了一些示例,它说要在代码周围使用 $() ,但它不起作用,请任何人帮助我。
【问题讨论】:
-
听起来您正在为不支持进程替换的脚本使用
/bin/sh。尝试使用/bin/bash。 -
嗨 Etan,我尝试了
#!/bin.sh和#!/bin/bash在这两种情况下都收到错误./a.sh: syntax error at line 2:vars=$' unexpected`` -
你是如何运行脚本的?它有执行权限吗?那 sn-p 只有一行。如果您从第 2 行得到错误,我们可能无法帮助您(第 2 行的错误意味着
bash接受了<()语法)。