commandlinefu.com is the place to record those command-line gems that you return to again and again.
You can sign-in using OpenID credentials, or register a traditional username and password.
Subscribe to the feed for:
Shows only IP-addresses of ifconfig except 127.0.0.0/8.
I fixed the script to work on more systems and configs
/inet/!d; #grep inet
/127.0/d; # grep -v 127.0
/dr:\s/d; # grep -v dr:
s/^.*:\(.*\)B.*$/\1/ # remove everything exept between : and B
There are 3 alternatives - vote for the best!
Shows the interface and the ip-address
This also works on non-Linux machines. If you have GNU sed you can do it more elegantly:
ifconfig | sed -n 's/^\s*inet \(addr:\)\?\([^\s]*\) .*/\2/;T;/^127\./d;p'
This is what we use.
You can grep -v 127.0.0.1 if you wish.
short enough to be tweetable
If you can do better, submit your command here.
You must be signed in to comment.