[Top][All Lists]

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

Re: grep bug report: --only-matching fails

From: Tony Abou-Assaleh
Subject: Re: grep bug report: --only-matching fails
Date: Sat, 29 Sep 2007 22:41:27 -0300 (ADT)

> But in a sense the -o and the * are conflicting: the [1234567890]*
> will match anything, also zero digits, and the -o should then print
> all these occurrences of zero digits...

grep-5.2.3 does not print empty matches when -o is specified. This
behaviour sounds reasonable to me, even though it is inconsistent with
general matching:

% echo 'abc1234abc' | ./grep  'z*'
% echo 'abc1234abc' | ./grep -o 'z*'

As you can see, the same pattern produced a match without options, and
didn't produce any matches with -o. It is not clear to me at this point
weather to treat this as a bug or a feature. One one hand, empty matches
are usually representative of errors in the pattern, and printing every
one of them with -o will clutter the output. On the other hand, this makes
the behaviour of -o radically different from without it, especially when
searching multiple files and expecting the names of the matching files to
be printed. What do others think?



Tony Abou-Assaleh
Email:    address@hidden
Web site: http://tony.abou-assaleh.net
----------------------[THE END]----------------------

reply via email to

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