How to get the IP address programmatically from an interface name in bash.
Last active
September 26, 2015 16:25
-
-
Save TGWolf/1db199c380de7cb8d43a to your computer and use it in GitHub Desktop.
How to get the IP address programmatically from an interface name in bash.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
IP=`/sbin/ifconfig eth0 2>/dev/null|awk '/inet addr:/ {print $2}'|sed 's/addr://'` | |
echo $IP |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment