Tanto bash como zsh admiten la sustitución de procesos (Process Substitution)
La sintaxis es:
<(command) o >(command)
Por ejemplo:
$ cat <(ls) #把<(ls)当一个临时文件,文件内容是ls的结果,cat这个临时文件 $ ls > >(cat) #把>(cat)当成临时文件,ls的结果重定向到这个文件,最后这个文件被cat
Usa la sustitución de procesos para redirigir por separado las salidas estándar y de error:
$ some_command > >(/bin/cmd_for_stdout) 2> >(/bin/cmd_for_stderr)
Ver también aquí:
http://www.ibm.com/developerworks/cn/aix/library/au-satzsh.htmlAllí hay más ejemplos, como:
#使用临时文件来将一个文件中的字段提取并重新组合到另一个文件中 $ cut -f1 fileone >t1 $ cut -f5 filetone >t5 $ paste t1 t5 #用进程替换可以无需临时文件完成此任务 $ paste -d: <(cut -d: -f1 /etc/passwd) <(cut -d: -f5 /etc/passwd) #进程替换支持嵌套 $ sort <(egrep -v '^#' <(paste -d: <(cut -d: -f5 /etc/passwd) <(cut -d: -f1 /etc/passwd) ) )
Dirección original: http://hongjiang.info/shell-process-substitution/