我正在尝试使用 cmp 来比较两个命令(Bourne shell)的输出:
cmp <(ls $file1) <(ls $file2)
它在 Bash 中运行良好,但在 Bourne 中无法运行。有什么解决办法吗?非常感谢!
最佳答案
进程替换是(或曾经)使用命名管道实现的。您可以使用 mkfifo
直接重新创建相同的行为:
mkfifo pipe1 pipe2
ls $file1 > pipe1 &
ls $file2 > pipe2 &
cmp pipe1 pipe2
rm pipe1 pipe2
但是除了性能之外,与考虑常规文件相比,您不会获得太多 yield ......
关于shell - Bourne Shell 中是否有像 Bash 中那样的进程替换?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39812507/