【问题标题】:is there process substitution in Bourne Shell like that in Bash?Bourne Shell 中是否有像 Bash 中那样的进程替换?
【发布时间】:2016-10-01 23:39:13
【问题描述】:

我正在尝试使用 cmp 比较两个命令的输出(Bourne shell):

cmp

它在 Bash 中运行良好,但在 Bourne 中无法运行。有什么解决办法吗?非常感谢!

【问题讨论】:

  • 不,没有。
  • 我也希望如此。如果我有可用的进程替换,我的 shell 脚本会更容易理解,购买我的大多数脚本都兼容 Bourne shell 我必须记住一些脚本需要用 bash 执行

标签: shell unix process substitution


【解决方案1】:

进程替换是(或曾经是)使用命名管道实现的。您可以直接使用mkfifo 重新创建相同的行为:

mkfifo pipe1 pipe2
ls $file1 > pipe1 &
ls $file2 > pipe2 &
cmp pipe1 pipe2
rm pipe1 pipe2

但除了表演之外,与常规文件相比,您不会获得太多...

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-08-13
    • 1970-01-01
    • 2013-03-05
    • 1970-01-01
    • 1970-01-01
    • 2015-12-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多