Skip to main content
deleted 182 characters in body
Source Link
Rui F Ribeiro
  • 58k
  • 28
  • 156
  • 238

There is a variant of grep that supports this feature for large sets of strings, try

fileWithListOfSearchTargets=myFileOfSearchTargets.txt

fgrep -f ${fileWithListOfSearchTargets} file1 file2 ... filen

(The variable and filenames are meant to be self-documenting, you can use any name you like)

You have to enter all your search strings into the file.

No leading or trailing spaces unless you expect those to match in your filelist. There is a limit to the size that most fgreps can process. Don't try to cram 10K lines into one file.

I hope this helps.

P.S. as you appear to be a new user, if you get an answer that helps you please remember to mark it as accepted, and/or give it a + (or -) as a useful answer.

There is a variant of grep that supports this feature for large sets of strings, try

fileWithListOfSearchTargets=myFileOfSearchTargets.txt

fgrep -f ${fileWithListOfSearchTargets} file1 file2 ... filen

(The variable and filenames are meant to be self-documenting, you can use any name you like)

You have to enter all your search strings into the file.

No leading or trailing spaces unless you expect those to match in your filelist. There is a limit to the size that most fgreps can process. Don't try to cram 10K lines into one file.

I hope this helps.

P.S. as you appear to be a new user, if you get an answer that helps you please remember to mark it as accepted, and/or give it a + (or -) as a useful answer.

There is a variant of grep that supports this feature for large sets of strings, try

fileWithListOfSearchTargets=myFileOfSearchTargets.txt

fgrep -f ${fileWithListOfSearchTargets} file1 file2 ... filen

(The variable and filenames are meant to be self-documenting, you can use any name you like)

You have to enter all your search strings into the file.

No leading or trailing spaces unless you expect those to match in your filelist. There is a limit to the size that most fgreps can process. Don't try to cram 10K lines into one file.

Post Migrated Here from stackoverflow.com (revisions)
Source Link
shellter
  • 709
  • 7
  • 10

There is a variant of grep that supports this feature for large sets of strings, try

fileWithListOfSearchTargets=myFileOfSearchTargets.txt

fgrep -f ${fileWithListOfSearchTargets} file1 file2 ... filen

(The variable and filenames are meant to be self-documenting, you can use any name you like)

You have to enter all your search strings into the file.

No leading or trailing spaces unless you expect those to match in your filelist. There is a limit to the size that most fgreps can process. Don't try to cram 10K lines into one file.

I hope this helps.

P.S. as you appear to be a new user, if you get an answer that helps you please remember to mark it as accepted, and/or give it a + (or -) as a useful answer.