Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 20 Oct 2005 13:11:17 -0700
From:      David Kirchner <dpk@dpk.net>
To:        James Long <stable@museum.rain.com>
Cc:        freebsd-stable@freebsd.org
Subject:   Re: bzegrep behaviour not consistent with egrep?
Message-ID:  <35c231bf0510201311i26d9ba61y956c797e380f79ee@mail.gmail.com>
In-Reply-To: <20051020194725.GA10376@ns.museum.rain.com>
References:  <20051020194725.GA10376@ns.museum.rain.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On 10/20/05, James Long <stable@museum.rain.com> wrote:
> Should these two commands produce identical output?
>
> $ bzegrep "38436|41640" /var/log/maillog.0.bz2 | wc -l
>        0
> $ bzcat /var/log/maillog.0.bz2 | egrep "38436|41640" | wc -l
>      121

Yep. Looks like a bug in the grep code. It looks at the name of the
program to determine what to do. It first checks for 'z' and then 'b'
at the first character, and then increments the pointer. With 'zgrep'
and 'zegrep', that works fine, since it becomes 'grep' and 'egrep'.
With 'bzegrep' it becomes 'zegrep', after it's already looked for 'z'.
It doesn't know what to make of that so it just goes to the default
'grep'.

You can use:

egrep -J "38436|41640" /var/log/maillog.0.bz2

which will filter the file through bzip2.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?35c231bf0510201311i26d9ba61y956c797e380f79ee>