2018-08-08

Process substitution on Linux
进程替换命令格式:

(command)
<(command)
即将命令的输出(或输入)视为文件。

bash$ echo >(true)
/dev/fd/63 ,产生/dev/fd/63这样的文件名称

必须用bash,如果用/bin/sh s.sh ,而 s.sh 里面用了进程替换就会报错syntax error near unexpected token `<'

The syntax you've used is a bash extension to the basic shell syntax, so you must take care to run your script with bash. (Ksh also has >(…) process substitution but doesn't support it after a redirection. Zsh would be fine.)

Given the error message you're getting, you are running this script in bash, but in its POSIX compatibility mode, not in full bash mode. Take care to invoke your script with an explicit #!/bin/bash line. #!/bin/sh won't do, even if /bin/sh is a symbolic link to bash, because bash runs in POSIX mode if it's invoked under the name sh. Always invoke bash by name if you use bash features.
参考:https://stackoverflow.com/questions/12120598/syntax-error-in-shell-script-with-process-substitution
https://stackoverflow.com/questions/31371672/how-to-use-process-substitution-in-a-script-run-with-sh-instead-of-bash

参考:http://www.tldp.org/LDP/abs/html/process-sub.html
http://mywiki.wooledge.org/BashFAQ/024
https://www.redpill-linpro.com/sysadvent/2015/12/12/bash-process-substitution.html

set +m
shopt -s lastpipe

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 12,199评论 0 10
  • Getting Started Use the Current Stable Version (7.1) Buil...
    Leonzai阅读 6,017评论 0 3
  • 投射儿子健康快乐静心高效的学习!投射儿子中考顺利,考上理想的高中!投射儿子心想事成,梦想成真!投射家人平安健康每一...
    菩提花yyw阅读 1,657评论 0 0
  • “一个女孩必备的两样东西,优雅和美丽。” ----Coco Chanel 香奈儿曾经说过:“一个女孩必备的两样东...
    英曼绘生活阅读 3,255评论 2 3
  • 水 不动声色 叶子颤抖是拥抱的深度 十里荷塘夜夜不眠 静听蛙声咕咚 春天横吹短笛飞来飞去 一头扎进荷叶深处 憋口气...
    诗人银莲阅读 2,540评论 0 1

友情链接更多精彩内容