Finding files containing multiple words
How to find all the files containing all the words of a list anywhere in them?
list="hello world"
cmd=ls
for i in $list; do
cmd="$cmd | xargs -0 grep -l $i";
done
eval $cmd
(not tested with files containing spaces; -0
should take care of that, but don’t take my word for it. (oh, and it’s “minus zero”, for you with crappy fonts out there))
You may replace ls
with find
if you’re searching through a tree.