Pipe output to use as the search specification for grep on Linux
Try
grep ... | fgrep -f - file1 file2 ...
You need to use xargs
's -i
switch:
grep ... | xargs -ifoo grep foo file_in_which_to_search
This takes the option after -i
(foo
in this case) and replaces every occurrence of it in the command with the output of the first grep
.
This is the same as:
grep `grep ...` file_in_which_to_search