Created
February 26, 2016 05:40
-
-
Save mosuka/371ae5ba9f164def8eb8 to your computer and use it in GitHub Desktop.
Extract IP address from ifconfig command.
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
ip addr show | grep -e "inet[^6]" |\ | |
sed -e "s/.*inet[^6][^0-9]*\([0-9.]*\)[^0-9]*.*/\1/" |\ | |
grep -v "^127\." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Of possible interest:
ip addr show |awk '/eth[0,1,2,3]/ && /inet/ {print $2}'
Sample output:
172.22.114.159/23
169.254.84.242/16