Today I needed to get the ip address as part of script to configure the "/etc/hosts" file. The command to get the IP is a one line command:$ ifconfig | grep 'inet addr:' | grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1 }'
Thats all it takes to get the IP address(es) of the current interfaces excluding the loop back adapter. Other variants of *nix and windows may require different commands.
No comments:
Post a Comment