Problem using grep to search for multiple strings listed in a file
Hi - I'm having a problem using grep to extract lines from a data file that contain one of several different strings. I am trying to load the strings from a file - hence, the code I'm using is:
grep -f file.containing.strings data.file When I run this, grep doesn't return any output. The strings are listed in my file one per line, and I have tried listing the strings in this file both with and without single quotation marks. I have also checked that (at least some of) the strings I'm searching for are definitely in the data file, using the regular: grep 'string' data.file Any ideas what I'm doing wrong? Thanks! |
Quote:
Daniel B. Martin |
If your strings are not regular expressions you should use -F to indicate that:
Code:
grep -Ff file.containing.strings data.file |
Hi - thanks for the responses but I've just managed to solve the problem. I originally created the input file under Windows, so it had Windows line ends (which I was copying and pasting into new files created in Linux). I've just resaved it with Linux line ends and, magically, grep is now working on my file!
Hopefully this might at least help someone else to avoid doing this in future! Cheers, Nick |
All times are GMT -5. The time now is 01:51 AM. |