Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've created a text file (in Windows) with the text patterns I wish to search for. Using the -f switch, grep only searches for the last pattern in the list. If there is a blank line, grep finds nothing.

grep -a -A 4 -f Grep.txt my.file

Any suggestions to get this to work?

Thanks

share|improve this question

Check to be sure each line in your pattern file ends with only a \n character Unix-style, not a Windows-style \r\n combination. To the Cygwin grep, a \r is an ordinary character that it would try to match.

You can delete the \r characters with tr:

tr -d "\r" < infile > outfile
share|improve this answer
    
That was it. Another option is to use NotePad++ to save in Unix text format. – Roy Jensen Nov 26 '12 at 20:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .