grep question
Steve Bertrand
iaccounts at ibctech.ca
Wed Jul 4 22:26:37 UTC 2007
> 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
More information about the freebsd-questions
mailing list