<分区>
我运行一个包含这样命令的文件
comm -3 <(cut -f 1 -d' ' <./atoz |sort) <(cut -f 1 -d' '
在文件外运行成功。 但是我得到错误:“file1:1:file1:语法错误:”(“意外”,当我键入
sh file1 file2 并尝试从 file1 运行命令。
该文件没有任何#!/bin/bash 或 .sh 后缀,因为我没有解决此类问题的背景..
有人知道怎么解决吗?非常感谢
<分区>
我运行一个包含这样命令的文件
comm -3 <(cut -f 1 -d' ' <./atoz |sort) <(cut -f 1 -d' '
在文件外运行成功。 但是我得到错误:“file1:1:file1:语法错误:”(“意外”,当我键入
sh file1 file2 并尝试从 file1 运行命令。
该文件没有任何#!/bin/bash 或 .sh 后缀,因为我没有解决此类问题的背景..
有人知道怎么解决吗?非常感谢
最佳答案
进程替换 ( <()
) 是 bash 的一个特性。 /bin/sh
不支持它, 这保证只有 POSIX sh specification 中存在的特征(在符合 1992 年或更新的 POSIX 规范的平台上;在旧平台上,它可能是 1970 年代的 Bourne)。
使用 bash yourscript
, 或 #!/bin/bash
shebang,运行此文件。
关于linux - 语法错误 : "(" unexpected when sh a file,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44617010/