in reply to Searching multiple expressions in multiple Files

If you have fgrep and sort available then you could do it like this:

fgrep -o -f list_of_strings_file directory/* | sort -u

Replies are listed 'Best First'.
Re^2: Searching multiple expressions in multiple Files
by planetscape (Chancellor) on Mar 31, 2009 at 12:44 UTC
Re^2: Searching multiple expressions in multiple Files (perl-5.10 vs. fgrep)
by almut (Canon) on Mar 31, 2009 at 14:35 UTC

    A quick benchmark shows that fgrep is even about three times as fast as perl. (For 5.10.0, that is — with 5.8.8, the ratio is even worse... considerably!)  Such a large difference is somewhat surprising (to me). I would've expected perl-5.10 to be about on par with fgrep. So, please, someone point out what I've done wrong in my benchmark... :)

    perl-5.10.0:

    Rate perl fgrep perl 30.8/s -- -71% fgrep 106/s 246% --

    perl-5.8.8:

    s/iter perl fgrep perl 9.38 -- -100% fgrep 3.00e-04 3124967% --

    (In this particular reported case, none of the search words were found in $^X (the perl binary), so all strings had to be tested.)

Re^2: Searching multiple expressions in multiple Files
by technoz (Initiate) on Mar 31, 2009 at 13:22 UTC
    Thanks for the suggestions.
    Unfortunately I dont have perl or the script to try upon till tomorrow. I will try and let you know the results.