我在运行带有参数的 shell 脚本时遇到问题。此命令直接在 Linux 上运行有效:
comm -13 <(sort /tmp/f1.txt) <(sort /tmp/f2.txt) > /tmp/f3.txt
如果我尝试使用此命令发送参数来运行此 shell 脚本,则会收到以下错误:
test.sh: line 6: syntax error near unexpected token `('
'est.sh: line 6: `comm -13 <(sort $1) <(sort $2) > $3
这是我的外壳代码:
#!/bin/bash
comm -13 <(sort $1) <(sort $2) > $3
我使用以下命令运行它:
sh test.sh /tmp/f1.txt /tmp/f2.txt /tmp/f3.txt
我已经没有想法可能出了什么问题。请协助。
谢谢你,-安德烈