Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 04 Jul 2007 18:26:48 -0400
From:      Steve Bertrand <iaccounts@ibctech.ca>
To:        ann kok <annkok2001@yahoo.com>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: grep question
Message-ID:  <468C1EA8.1040809@ibctech.ca>
In-Reply-To: <445024.12701.qm@web53303.mail.re2.yahoo.com>
References:  <445024.12701.qm@web53303.mail.re2.yahoo.com>

next in thread | previous in thread | raw e-mail | index | archive | help
> 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



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