From owner-freebsd-stable@FreeBSD.ORG Thu Oct 20 20:11:18 2005 Return-Path: X-Original-To: freebsd-stable@freebsd.org Delivered-To: freebsd-stable@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id F020D16A41F for ; Thu, 20 Oct 2005 20:11:18 +0000 (GMT) (envelope-from dpkirchner@gmail.com) Received: from xproxy.gmail.com (xproxy.gmail.com [66.249.82.196]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8A83443D5A for ; Thu, 20 Oct 2005 20:11:18 +0000 (GMT) (envelope-from dpkirchner@gmail.com) Received: by xproxy.gmail.com with SMTP id t13so316433wxc for ; Thu, 20 Oct 2005 13:11:17 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=IhLwQis/c+IIai0J6po436NMKovsqrdZEomAfx17lYv2Mxb1jy/SXA6sklsamIBFrYar1dTnWkQayGY01OKPsP82kBSSHlmxbSsKhCC2daEshPWIkV3bCuDGPzFR839ZPrIiy0+KAJGqDnfbPIJ0wO3yikcgs9UH6bPzsnEvcaI= Received: by 10.70.65.17 with SMTP id n17mr1229019wxa; Thu, 20 Oct 2005 13:11:17 -0700 (PDT) Received: by 10.70.104.18 with HTTP; Thu, 20 Oct 2005 13:11:17 -0700 (PDT) Message-ID: <35c231bf0510201311i26d9ba61y956c797e380f79ee@mail.gmail.com> Date: Thu, 20 Oct 2005 13:11:17 -0700 From: David Kirchner Sender: dpkirchner@gmail.com To: James Long In-Reply-To: <20051020194725.GA10376@ns.museum.rain.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <20051020194725.GA10376@ns.museum.rain.com> Cc: freebsd-stable@freebsd.org Subject: Re: bzegrep behaviour not consistent with egrep? X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 Oct 2005 20:11:19 -0000 On 10/20/05, James Long 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.