0

To search in Linux for a file that contains a string, one would usually use:

grep "search string" *

But what if you instead want to pass a file (such as mySearchString.txt, which obviously would contain the string "search string" - without the double quotes... unless they or single quotes are required?) to grep for it to use to search for that string?

grep <mySearchString.txt *

Doesn't seem to work...

melpomene
  • 84,125
  • 8
  • 85
  • 148
MaxZ
  • 723
  • 1
  • 6
  • 10
  • Possible duplicate of [How to make "grep" read patterns from a file?](http://stackoverflow.com/questions/7027306/how-to-make-grep-read-patterns-from-a-file) – Benjamin W. Jan 22 '17 at 18:32
  • Or [How to grep with a list of words](http://stackoverflow.com/questions/17863301/how-to-grep-with-a-list-of-words) – Benjamin W. Jan 22 '17 at 18:32

1 Answers1

1

man grep:

-f file
--file=file

Obtain patterns from file, one per line. If this option is used multiple times or is combined with the -e (--regexp) option, search for all patterns given. The empty file contains zero patterns, and therefore matches nothing. (-f is specified by POSIX.)

Community
  • 1
  • 1
melpomene
  • 84,125
  • 8
  • 85
  • 148