On 04/18/2011 06:11 AM, Daniel Schade wrote:
> Dear gnu.org Team,
> 
> I have useed grep to search for double minus in a string and grep told me an
> error, take a look to the samples
> 
> [root@myhost]# echo "Test --" | grep -i '--'

This is not a bug in grep, but a misunderstanding on your part at how to
delimit the end of options.

Try:

echo "Test --" | grep -i -- --

instead.  The first -- tells grep that all remaining arguments are not
options, but literal operands, so that the second -- can be used as the
search pattern.

This behavior is required by POSIX for most utilities (there are a few
exceptions, such as echo, but in general -- processing is a useful idiom
to know).

> [root@myhost]# grep --version
> grep (GNU grep) 2.5.1

You may want to consider upgrading - the latest stable version is 2.7,
and fixes several bugs present in 2.5.1.

-- 
Eric Blake   [email protected]    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

  • grep Daniel Schade
    • Re: grep Eric Blake

Reply via email to