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
网友评论