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

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

possible bug with gnu grep and -v flag


From: Alex J. Avriette
Subject: possible bug with gnu grep and -v flag
Date: Fri, 14 Sep 2007 15:28:58 -0400

I am using gnu grep on Darwin:

Darwin gordon 8.10.1 Darwin Kernel Version 8.10.1: Wed May 23 16:33:00 PDT
2007; root:xnu-792.22.5~1/RELEASE_I386 i386 i386

and

grep (GNU grep) 2.5.1

Copyright 1988, 1992-1999, 2000, 2001 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

The behavior I am seeing that I am not expecting, per the manual page, is
the following:

gordon% curl -sl  ftp://iso.netbsd.org/pub/NetBSD/iso/3.1/ | grep -e iso -e
i386  -v torrent
grep: torrent: No such file or directory

I would expect that grep, reading from standard in, would not print lines
matching "torrent." I have tried variations of the above, including -ve
torrent, and even some more exotic regular expression type things that still
don't come close to what I'm doing (which I think is apparent).

gordon% curl -s  ftp://iso.netbsd.org/pub/NetBSD/iso/3.1/ | tr -s ' ' | cut
-d ' ' -f 9 | grep -E 'i386(cd|pkg)-3.1.iso\b'
i386cd-3.1.iso
i386cd-3.1.iso.torrent
i386pkg-3.1.iso
i386pkg-3.1.iso.torrent

>From the manpage, we see the following text:

The  caret ^ and the dollar sign $ are metacharacters that respectively
match the empty string at the beginning and end of a line.  The symbols \<
and \> respectively match the empty string at the beginning and end of a
word.  The symbol \b matches the empty string at  the  edge  of a word,  and
\B matches the empty string provided it's not at the edge of a word.

So, first, I'd expect the \b at the end of ".iso" in the above "extended"
(-E) expression to represent essentially an end-of-line, therefore not
matching the files which end in .torrent. Further, when I use the caret
and/or dollar sign, I get still more perplexing returns:

gordon% curl -s ftp://iso.netbsd.org/pub/NetBSD/iso/3.1/ | grep -E
'i386(cd|pkg)-3.1.iso'
-rw-r--r--  1 1369  netbsd  217808896 Nov  2  2006 i386cd-3.1.iso
-r--r--r--  1 1136  netbsd      16789 Nov  3  2006 i386cd-3.1.iso.torrent
-rw-r--r--  1 1127  netbsd  728014848 Feb 18  2007 i386pkg-3.1.iso
-rw-rw-r--  1 1115  netbsd      55730 Apr 20 21:18 i386pkg-3.1.iso.torrent
gordon% curl -s ftp://iso.netbsd.org/pub/NetBSD/iso/3.1/ | grep -E
'i386(cd|pkg)-3.1.iso$'
gordon%


So I'm not sure if I'm doing something wrong here, but it seems to me from
the manpage for grep, that it is behaving perhaps not as it is described to.
The particular thing that bothers me most is that adding a "-ev *string*"
says "grep: string: No such file or directory". Since we're reading from
standard in, it seems improper for it to be looking for a file.

Apologies for sending you this HTML formatted email, but it was easier for
me to compose this way, and I'm sure on your end emacs or whichever can
handle it fine.

Thanks for your time,
Alex


-- 
Alex Avriette
address@hidden
skype:avriette / +1-858-736-9446


reply via email to

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