Passing a file with multiple patterns to grep
- by Michael Goldshteyn
Let's say we have two files.
match.txt: A file containing patterns to match:
fed ghi
tsr qpo
data.txt: A file containing lines of text:
abc fed ghi jkl
mno pqr stu vwx
zyx wvu tsr qpo
Now, I want to issue a grep command that should return the first and third line from data.txt:
abc fed ghi jkl
zyx wvu tsr qpo
... because each of these two lines match one of the patterns in match.txt.
I have tried:
grep -F -f match.txt data.txt
but that returns no results.
grep info: GNU grep 2.6.3 (cygwin)
OS info: Windows 2008 R2
Update: It seems, that grep is confused by the space in the search pattern lines, but with the -F flag, it should be treating each line in match.txt as an individual match pattern.