Both bash and zsh support Process Substitution

The syntax is:

<(command) 或 >(command)

For example:

$ cat <(ls)       #把<(ls)当一个临时文件,文件内容是ls的结果,cat这个临时文件
 
$ ls > >(cat)      #把>(cat)当成临时文件,ls的结果重定向到这个文件,最后这个文件被cat

Use process substitution to redirect stdout and stderr output separately:

$ some_command > >(/bin/cmd_for_stdout) 2> >(/bin/cmd_for_stderr)

Also refer to here:

http://www.ibm.com/developerworks/cn/aix/library/au-satzsh.html

There are more examples, such as:

#使用临时文件来将一个文件中的字段提取并重新组合到另一个文件中
$ 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) ) )

Original URL: http://hongjiang.info/shell-process-substitution/