If I search for multiple search strings in grep
: usually just do:
grep "search1\|search2" somefolder/*.txt
but, what if I have 100 or more search strings? Can I say like this:
grep "stringPattern.txt" somefolder/*.txt
where stringPattern.txt
is a file containing a list of words I need to search in *.txt
.
Best Answer
grep
has the-f
flag exactly for this, use:Where in the
patternfile
the search patterns are separated line by line.