Reputation: 547
I need to grep to tons (10k+) of files for specific words. now that returns a list of files that i also need to grep for another word.
i found on that grep can do this so i use:
grep -rl word1 *
which returns the list of files i want to check. now from these files (100+), i need to grep another word. so i have to do another grep
vim `grep word2 `grep -rl word1 *``
but that hangs, and it does not do anything,
why?
Upvotes: 18
Views: 254
Reputation: 49867
Because you have a double `, you need to use the $()
vi `grep -l 'word2' $(grep -rl 'word1' *)`
Or you can use nested $(...)
(like goblar mentioned)
vi $(grep -l 'word2' $(grep -rl 'word1' *))
Upvotes: 35
Reputation: 143061
grep -rl 'word1' | xargs grep -l 'word2' | xargs vi
is another option.
Upvotes: 20