I’m trying to find a better way to determine which files in a given directory contain all of a given set of search strings. The way I’m currently doing it seems awkward.
For example, if I want to find which files contain “aaa”, “bbb”, “ccc”, and “ddd” I would do:
grep -l "aaa" * > out1
grep -l "bbb" `cat out1` > out2
grep -l "ccc" `cat out2` > out3
grep -l "ddd" `cat out3` > out4
cat out4
rm out1 out2 out3 out4
As you can see, this seems clumsy. Any better ideas?
EDIT: I’m on a Solaris 10 machine
You can use xargs to chain the grep calls together: