How to get an IP Address from command line?
Hi there,
Here is a fun tidbit for a Thursday. Is there a command that will return me just the IP Address for a given interface. Something akin to.... #getip eth0 192.168.1.60 # And yes I know I could parse out the results from ifconfig, but if there is another way, please let me know. |
Why don't you create a simple script and put it on your PATH?
Code:
#/bin/bash |
You could do it by extracting it from the config file for the interface.
e.g. for RH/FC: Code:
grep IPADDR /etc/sysconfig/network-scripts/ifcfg-eth0 |awk -F= '{print $2}' Code:
ifconfig eth0 |grep "inet addr" |awk '{print $2}' |awk -F: '{print $2}' Code:
#!/bin/bash |
Just a suggestion:
Code:
#!/bin/bash edit: beaten by jlightner... damn! |
Thanks!
Hi all,
Thanks for the replys. I knew about the ifconfig. Just checking to see if there was something else. Thanks again. Big Dog XII (woof) |
All times are GMT -5. The time now is 10:11 AM. |