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:
and, a lot uglier, with sed:
ifconfig | sed -n '/inet addr:/s/[^:]\+:\(\S\+\).*/\1/p'
Wanted to be shorter than the perl version. Still think that the perl version is the best..
There is 1 alternative - vote for the best!
Fetches the IPs and ONLY the IPs from ifconfig. Simplest, shortest, cleanest.
Perl is too good to be true...
(P.S.: credit should go to Peteris Krumins at catonmat.net)
The initial version of this command also outputted extra empty lines, so it went like this:
This happened on Ubuntu, i haven't tested on anything else.
If you can do better, submit your command here.
You must be signed in to comment.