What is the correct way to redirect the output of multiple commands as input for another command?
e.g.
$ command < (command2 | grep pattern)
What is the correct way to redirect the output of multiple commands as input for another command? e.g.
|
|||
(This refers to bash in case of doubt) The output of one command or one pipeline can be made the input of another command by creating a (or extending the existing) pipeline:
Several commands (including pipelines) can be combined with a subshell or a list (group command). This combination becomes the first part of the pipeline then:
Another possibility is a "here string" (or even a "here document"):
Other cases Command substitution is used when the output shall be part of a command line i.e. if one command shall see the output of another as its own parameter:
echo sees the output of Process substitution makes the output of another process appearing as the content of a (non-seekable) file given as parameter on the command line.
looks to grep like
|
|||
|
You have to execute the commands using the command substitution syntax.
|
|||||||||||||
|
command2 | grep pattern | command
– Hauke Laging Apr 28 '13 at 9:17<( .... )
syntax is primarily used in those cases where a simple pipeline does not work, either because some program refuses to read from standard input and requires a file argument, or because there are several commands whose output should be fed into one other command, i.e.,cmd <(cmd1) <(cmd2)
. – Uwe Apr 28 '13 at 9:42