Bash – the name of the shell feature `>(tee copyError.txt >&2)`

bashshell

I need to log stdout and stderr to logfiles, but only show the error messages on screen. I can do this with:

cp -rpv a/* b 1> copyLog.txt 2> >(tee copyError.txt >&2) 

Which I found somewhere in the web.

I just want to know how this >(tee copyError.txt >&2) thing is called? I can't google for it, since Google ignores characters like angle brackets and the parentheses..

Best Answer

From man bash:

   Process Substitution
       Process substitution is supported  on  systems  that  support
       named  pipes  (FIFOs)  or  the  /dev/fd method of naming open
       files.  It takes the form of <(list) or >(list).  The process
       list  is  run with its input or output connected to a FIFO or
       some file in /dev/fd.  The name of this file is passed as  an
       argument  to  the current command as the result of the expan‐
       sion.  If the >(list) form is used, writing to the file  will
       provide  input  for  list.   If the <(list) form is used, the
       file passed as an argument should be read to obtain the  out‐
       put of list.

You can search manpages by pressing / and then typing your search string, which is a good way of finding information like this. It does of course require that you know in which manpage to search :)

You have to quote the ( though, because it has a special meaning when searching. To find the relevant section in the bash manpage, type />\(.

Related Question