2

Here I found a shell input construction I've never seen before but that works. It reads

comm <(fancy input mangling) <(another input construction)

How does this work in a normal stdin/stdout/stderr program, how does the program distinguish between the first and the second inputfile?

1 Answer 1

2

man and grep are your friends.

$ man bash | grep -C2 '<('
   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 expansion.  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 output of list.
2
  • So '<()' actually creates a real file who's name is given to the (in this case) comm process. I was thrown off guard by the '<' symbol, which suggests something related to pipes and redirection. bash -x ./k.sh <(cat 1.txt) <(cat 2.txt) + echo 'Parameter 1 : /dev/fd/63 Parameter 2 : /dev/fd/62' Parameter 1 : /dev/fd/63 Parameter 2 : /dev/fd/62 + diff -u /dev/fd/63 /dev/fd/62
    – JdeHaan
    Nov 30, 2016 at 13:57
  • A pipe can be a file too. See man mkfifo.
    – user147505
    Nov 30, 2016 at 14:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .