Download   Online Shop   Red Hat Network
Home  |  Products & Services  |  Support  |  Training  |  Partners  |  Documentation   
Red Hat Documentation

Overview | HOWTOs | mini-HOWTOs | FAQs | Linux Man-Pages

Process Substitution

3.18. Process Substitution

Process substitution is the counterpart to command substitution. Command substitution sets a variable to the result of a command, as in dir_contents=`ls -al` or xref=$( grep word datafile). Process substitution feeds the output of a process to another process (in other words, it sends the results of a command to another command).

  • (command)>

    <(command)

    These initiate process substitution. This uses a named pipe (temp file) to send the results of the process within parentheses to another process.

Note: There are no spaces between the parentheses and the "<" or ">". Space there would simply cause redirection from a subshell, rather than process substitution.

      cat <(ls -l)
      # Same as     ls -l | cat
      sort -k 9 <(ls -l /bin) <(ls -l /usr/bin) <(ls -l /usr/X11R6/bin)
      # Lists all the files in the 3 main 'bin' directories, and sorts by filename.
      # Note that three (count 'em) distinct commands are fed to 'sort'.
      

 

 
 
Search for:  on    Powered by Google
Products & Services   :   Download   :   Support   :   Training   :   Partners & Programs
© 2000 Red Hat, Inc. All right reserved.       About Red Hat   :   Legal statement   :   Privacy statement   :   Y2K statement   :   Contact Red Hat