Dada Lili
Dada Lili

Reputation: 135

Why the pipe command can not work

firefox $(grep -l "mysed" /home/test)  

the command can open all my file which contain the word mysed in firefox,when i change the command into the following,

grep -l "mysed" /home/test |  firefox 

why the firefox can not open the files selected by grep?

Upvotes: 0

Views: 84

Answers (2)

Vikdor
Vikdor

Reputation: 24134

The first command provides the files to be opened as command line arguments to Firefox whereas the second command provids them on the STDIN of Firefox doesnt interpret and so cannot open them.

Upvotes: 0

Femaref
Femaref

Reputation: 61497

Because a pipe doesn't apply parameters. A pipe redirects stdout from one process to stdin of another.

You can use xargs to achieve what you want:

grep -l "mysed" /home/test | xargs firefox 

Upvotes: 3

Related Questions