|
BASH extract ip addresses with grep
|
|
12-30-2009, 11:55 AM
(This post was last modified: 12-30-2009 11:56 AM by codecaine.)
Post: #1
|
|||
|
|||
|
BASH extract ip addresses with grep
ifconfig list you ip configurations and pipes it to grep. From grep I used a regular expression to extract the data.
Code: ifconfig | grep -Eo '\b[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}\b'output example 127.0.0.1 192.168.2.1 192.168.2.255 169.254.254.87 169.254.255.255 10.59.0.214 10.59.3.255 10.211.55.2 10.211.55.255 10.37.129.2 10.37.129.255 192.168.170.1 192.168.170.255 192.168.97.1 192.168.97.255 |
|||
|
12-30-2009, 06:45 PM
Post: #2
|
|||
|
|||
|
RE: BASH extract ip addresses with grep
Interesting way of getting IP-s, in Windows Batch File you can do it with "netstat -n" and it lists you !
"I dont know with what weapons World War 3 will be fought with, but i know World War 4 will be fought with stones and sticks" - Albert Einstein |
|||
|
12-30-2009, 07:20 PM
Post: #3
|
|||
|
|||
|
RE: BASH extract ip addresses with grep
yea but it doesn't just pull the ips out of each line. ipconfig list the ips too
. This command removes all other text but ips from a line if found
|
|||
|
« Next Oldest | Next Newest »
|








. This command removes all other text but ips from a line if found