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
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 > 121Yep. 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.
in message <20051020194725.GA10376@ns.museum.rain.com>, wrote James Long thusly...> > 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 > 121And more fun, try also "egrep -J| wc", which is similar to the 2d case above. Seems like the first "e" in "bzegrep" is erroneous. - Parv --
On Thursday 20 October 2005 04:57 pm, Parv wrote:> in message <20051020194725.GA10376@ns.museum.rain.com>, > wrote James Long thusly... > > > 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 > > 121Can you try the patch for src/gnu/usr.bin/grep/grep.c?> And more fun, try also "egrep -J| wc", which is similar to the 2d > case above.Can you elaborate the fun, please? Thanks, JK> Seems like the first "e" in "bzegrep" is erroneous. > - Parv-------------- next part -------------- A non-text attachment was scrubbed... Name: grep.diff Type: text/x-diff Size: 894 bytes Desc: not available Url : http://lists.freebsd.org/pipermail/freebsd-stable/attachments/20051020/c687fe34/grep.bin
> > > 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 > > Can you try the patch for src/gnu/usr.bin/grep/grep.c?The patch appears to fix my problem. Thank you! Jim ns : 15:00:10 /usr/src/gnu/usr.bin/grep# bzegrep "38436|41640" /var/log/maillog.0.bz2 | wc -l 121 ns : 15:01:23 /usr/src/gnu/usr.bin/grep# bzcat /var/log/maillog.0.bz2 | egrep "38436|41640" | wc -l 121