November 21, 2009

IFCONFIG

Is there a way to take just the internal IP address from the `ifconfig' command?  Creating a file and force the output to go to another file with all the `ifconfig' information that is useless to me, other than the internal IP.

 

Thanx;

Paranoia 

You could also do it this way, ...

You could also do it this way,

ifconfig | grep 'inet addr' | cut -d":" -f2 | cut -d" " -f1 > ipaddress.txt

Like  (0 likes)

I like using awk for this kind of stuff:...

I like using awk for this kind of stuff:

ifconfig | grep Bcast | awk -F ":" '{print $2}' | awk -F " " '{print $1}'>myipaddress.txt

Like  (0 likes)

create two blank files data.txt and myipaddress.txt so you wont get "files...

create two blank files data.txt and myipaddress.txt so you wont get "files does not exist error " once you have created the two blank files run the script and you should see your ipaddress in the file myipaddress.txt. cat myipaddress.txt simple and effective

rm data.txt; rm myipaddress.txt; /sbin/ifconfig | grep "Bcast" >> data.txt ; cut -c21-35 data.txt >> myipaddress.txt

Like  (0 likes)
Click Here!