From owner-freebsd-questions@FreeBSD.ORG Wed Jul 4 22:26:37 2007 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id CE78A16A400 for ; Wed, 4 Jul 2007 22:26:37 +0000 (UTC) (envelope-from iaccounts@ibctech.ca) Received: from pearl.ibctech.ca (pearl.ibctech.ca [208.70.104.210]) by mx1.freebsd.org (Postfix) with ESMTP id 70BD513C44B for ; Wed, 4 Jul 2007 22:26:37 +0000 (UTC) (envelope-from iaccounts@ibctech.ca) Received: (qmail 46448 invoked by uid 1002); 4 Jul 2007 22:26:36 -0000 Received: from iaccounts@ibctech.ca by pearl.ibctech.ca by uid 89 with qmail-scanner-1.22 (spamassassin: 2.64. Clear:RC:1(208.70.107.100):. Processed in 6.388031 secs); 04 Jul 2007 22:26:36 -0000 Received: from unknown (HELO ?192.168.1.210?) (steve@ibctech.ca@208.70.107.100) by pearl.ibctech.ca with (DHE-RSA-AES256-SHA encrypted) SMTP; 4 Jul 2007 22:26:29 -0000 Message-ID: <468C1EA8.1040809@ibctech.ca> Date: Wed, 04 Jul 2007 18:26:48 -0400 From: Steve Bertrand User-Agent: Thunderbird 2.0.0.4 (Windows/20070604) MIME-Version: 1.0 To: ann kok References: <445024.12701.qm@web53303.mail.re2.yahoo.com> In-Reply-To: <445024.12701.qm@web53303.mail.re2.yahoo.com> X-Enigmail-Version: 0.95.1 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: freebsd-questions@freebsd.org Subject: Re: grep question X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Jul 2007 22:26:37 -0000 > how can I use grep to have the output as 60.40.2.x > > eg: > 60.40.2.5 > 60.40.2.3 > 60.40.2.7 > > except 60.40.2x.x > > eg: > 60.40.20.5 > 60.40.23.6 > 60.40.25.7 I don't know if you WANT to have 2x, or just 2., it would of been better if you provided what you tried. Nonetheless, I've done both for you This would include 60.40.any.any: (eg: 60.40.171.199) grep "60.40.[0-9]\{1,\}.[0-9]\{1,\}" This would include 60.40.2.any (but not 60.40.2x): (eg: 60.40.2.199, not 60.40.20.199) grep "60.40.2.[0-9]\{1,\}" This would include 60.40.2any.any: (eg: 60.40.219.199 or 60.40.21.199) grep "60.40.2[0-9]\{1,\}.[0-9]\{1,\}" ...and this would include 60.40.2x.any (eg: 60.40.22.199, but not 60.40.212.199) grep "60.40.2[0-9]\{1\}." HTH, Steve