[Linux-disciples] Find all files matching all patterns
Adam Rosi-Kessel
adam at rosi-kessel.org
Tue Aug 22 17:16:37 EDT 2006
I can't think of an obviously better way to do it. There is a tool called
multi-line grep (aka mg) that you might want to check out. I don't think it
is exactly on point but you could probably use it to the same as below
slightly more efficiently.
Stephen R Laniel wrote:
> If I want to find all the files under dirName that match
> string1 and string2 and ... and stringN, I do
>
> grep -irl string1 dirName |xargs -i grep -il string2 '{}' |xargs -i grep -il string3 '{}' |... [more of the same up to stringN]
>
> Is there any better way to do this? I've written a little
> Perl script to do it:
> http://laniels.org/scripts/matches_all.pl.txt
>
> But I wonder if y'all have a better idea.
More information about the Linux-disciples
mailing list