bug-grep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Issue with reading regexes from a file


From: David Corlette
Subject: Issue with reading regexes from a file
Date: Tue, 04 Dec 2007 19:07:11 -0500

Hello there,

Not sure if this is a bug, a doc issue, or a misunderstanding as to what it's 
supposed to do, but I'm getting strange results when I attempt to use the "-f" 
option in combination with the '-P' option.

If I run this command:
grep -f test.pat test.txt
(where test.pat contains a couple regexes)
I get the expected ouput (lines in test.txt that match either pattern.

If, however, I use 
grep -P -f test.pat test.txt
I get no output if there is more than one line in the file.

According to the man page, grep is supposed to treat the file as if it's one 
regex per line (and, I assume although it's not documented, OR them together). 
This appears to work without -P.  But when -P is specified, this does not seem 
to work. This is under SuSE Linux ED10SP1.

Thoughts?

Thanks!

Details:

test.txt contains:
www.novell.com
www.schmoo.org
hello.com
matchme.com
novell

test1.pat contains (one line):
novell

test2.pat contains (two lines):
novell
com

grep -f test1.pat test.txt gives:
www.novell.com
novell

grep -f test2.pat test.txt gives:
www.novell.com
hello.com
matchme.com
novell


grep -P -f test1.pat test.txt gives:
www.novell.com
novell

grep -P -f test2.pat test.txt gives:
(null)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]