Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using grep to match ip quad

Status
Not open for further replies.

aswolff

Programmer
Jul 31, 2006
100
US
I am trying to use grep to find ip addresses in a file. I've tried all sorts of variants but none work. Can somebody help?

grep \b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b IP.txt
grep '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}' IP.txt
grep "\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b" IP.txt
grep '172.30.218.123' IP.txt <===This works!
grep '\d72.30.218.123' IP.xt <===Does not work!

What am I missing...?

TIA
 
And what about this ?
grep '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' IP.txt

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
This ended up working:

grep '[0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}' IP.txt


Thanks....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top