bug-gnu-utils
[Top][All Lists]
Advanced

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

"grep -o" skips some matching patterns


From: Roberto Gordo Saez
Subject: "grep -o" skips some matching patterns
Date: Tue, 30 Dec 2003 16:24:23 +0100
User-agent: Mutt/1.5.4i

I've been busy during several hours looking for a strange bug in some
(rather complex) scripts, but finally i've found what it seems to be a bug
with grep -o.

Consider this example:

$ echo abc0111def | grep "01*"
abc0111def
$ echo abc0111def | grep -o "01*"
0111

That's obvious, and work as expected both with and without -o.
Now, look at this one:

$ echo abc0111def | grep "[01]*"
abc0111def
$ echo abc0111def | grep -o "[01]*"

"grep -o" does not print the matching string, although the return value
indicates a successful match. However, removing the first characters from
the input does work:

$ echo 0111def | grep -o "[01]*"
0111

I've checked the code from the CVS and still has this "feature".

-- 
Roberto Gordo Saez - Free Software Engineer
Linalco "Especialistas en Linux y Software Libre"
http://www.linalco.com/  Tel: +34-914561700




reply via email to

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