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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do i awk the ip address from cat /etc/hosts ?

Status
Not open for further replies.

farley99

MIS
Feb 12, 2003
413
US
How do i awk the ip address from cat /etc/hosts ?
 
awk '{ if (match($0,"^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}"))
print substr($0,RSTART,RLENGTH) }' /etc/hosts
 
Or you could use something simple like:

awk '/^[0-9]/{print $1}' /etc/hosts

John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top