Re: find'ing files containing certain words (all of them) ...
On Sat, 21 Sep 2013 12:00:54 -0400
Albretch Mueller <lbrtchx@gmail.com> wrote:
> I have come to believe this is one of those problems that is not to
> be optimally solved with a script, but a programming language
>
> lbrtchx
>
>
Probably AWK could be a good compromise :)
words.awk:
BEGIN {
split(p,ws,"|");
n=1;
while (n in ws)
ff[n++]=0;
}
{
for (i=1;i<n;i++)
if ((ff[i]==0) && (match($0,ws[i])))
ff[i]=1;
}
END {
f=0;
i=1;
while ((f==0)&&(i<n)) {
if (ff[i++]==0)
f=1;
}
exit(f);
}
command line:
$ awk -v p="w1|...|wn" -f words.awk file.txt
Regards :)
--
http://mr.flossdaily.org
Reply to: