Created
March 14, 2016 09:42
-
-
Save carlessanagustin/272008d3824c47505ebf to your computer and use it in GitHub Desktop.
Get only the IP address
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
# method 1 | |
$ echo $(ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}') | |
# method 2 | |
$ echo $(ip -o -4 addr list eth0 | perl -n -e 'if (m{inet\s([\d\.]+)\/\d+\s}xms) { print $1 }') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment