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: The fix is to use this command: tr -d "\r" <match.txt | grep -F -f - text.txt
It seems that grep does not correctly respect windows line endings (CR/LF) for match files presented to it via the -f flag.