linux - 语法错误 : "(" unexpected when sh a file

标签 linux shell command

<分区>

我运行一个包含这样命令的文件

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/

相关文章:

linux - 如何从 shell 设置管道尺寸?

ios - mac/ios 从命令行设置 webrtc 并创建 .bash_profile

python - 在 python 中使用 gdb 命令

linux - 将 jps -vl 命令的输出分配给 shell 脚本中的变量

VBA Shell 并等待退出代码

c++ - 如何获取 system() 命令 qt c++ 的输出?

macos - 在山狮上安装 FFmpeg 1.1.2 "Fire Flower"

java - 如何在 Java 进程 Hits OutOfMemory Error 时自动创建 Heap Dump?

c - 如何暂停 pthread 程序的执行,以便检查线程的 pid 和 tgid?

php - 使用include()时的权限问题