How do I pipe the output of grep as the search pattern for another grep?
As an example:
grep | xargs grep
This is what I use to search for a file from a listing:
ls -la | grep 'file-in-which-to-search'
I tried this way , and it works great.
[opuser@vjmachine abc]$ cat a
not problem
all
problem
first
not to get
read problem
read not problem
[opuser@vjmachine abc]$ cat b
not problem xxy
problem abcd
read problem werwer
read not problem 98989
123 not problem 345
345 problem tyu
[opuser@vjmachine abc]$ grep -e "`grep problem a`" b --col
not problem xxy
problem abcd
read problem werwer
read not problem 98989
123 not problem 345
345 problem tyu
[opuser@vjmachine abc]$
I have found the following command to work using $() with my first command inside the parenthesis to have the shell execute it first.
grep $(dig +short) file
I use this to look through files for an IP address when I am given a host name.