Re: grep with file of patterns

John Cowan <[email protected]>
Newsgroups gmane.comp.gnu.utils.bugs
Message-ID <[email protected]>
Eli Zaretskii scripsit:
> > From: Al Buckingham <[email protected]>
> > Date: Fri, 3 Feb 2012 14:13:56 -0500
> > 
> > Only the last pattern in the text file of patterns is processed
> >  
> > C:\cygwin>grep --fixed-strings  --file=C:\patternlist.txt  C:\code.inc > C:\GREP_OUT.txt
> > Patternlist.txt contains two lines
> > function
> > class
> > 
> > Whatever pattern appears last in the file it is the one that is processed.
> > All other patterns are ignored.
> 
> Cannot reproduce this here, but I don't have Cygwin installed.
> 
> Things to check/do:
> 
>  . upgrade to the latest Grep from Cygwin
> 
>  . make sure patternlist.txt has Unix-style LF-only end-of-line format

This is almost certainly the problem.  When I tried this under Cygwin
with a DOS-style patternlist.txt, I reproduced the behavior; when I
converted it to Unix-style, all was well.  I'd guess that the CR at the
beginning of the first line is being treated as part of the pattern.
Just why the other CR is not, is a question.

-- 
John Cowan   [email protected]
    "Mr. Lane, if you ever wish anything that I can do, all you will have
        to do will be to send me a telegram asking and it will be done."
    "Mr. Hearst, if you ever get a telegram from me asking you to do
        anything, you can put the telegram down as a forgery."
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.