works on Linux and Solaris. I think it will work on nearly all *nix-es Show Sample Output
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) Show Sample Output
This is useful if you have need to do port forwarding and your router doesn't assign static IPs, you can add it to a script in a cron job that checks if you IP as recently changed or with a trigger script. This was tested on Mac OSX.
I prefer the ip command to ifconfig as ifconfig is supposedly going to be deprecated. Certain IP address aliases can only be seen with the ip command (such as the ones applied by RHCS).
Interfaces like lo can be omitted from the beginning, there are probably better ways of doing this, i'm a noob at awk. Show Sample Output
I've been using it in a script to build from scratch proxy servers. Show Sample Output
It uses the following GNU grep options: "-o" which shows only the matching part of the line and "-P" which allows the use of Perl regular expressions. Show Sample Output
Get mac address listed for all interfaces. Show Sample Output
For machines that have many ip blocks spanning different Class C's, this will show which ones. Show Sample Output
Quick and dirty hardware summary where lshw is not available. Requires util-linux, procps, pciutils, usbutils and net-tools, which should be preinstalled on most systems.
Sometimes, you don't really care about all the other information that ifconfig spits at you (however useful it may otherwise be). You just want an IP. This strips out all the crap and gives you exactly what you want. Show Sample Output
Simple and easy. No regex, no search and replace. Just clean, built-in tools.
Needed to get the Mac of various devices on a solaris box, but didn't have root. This command used awk to display the Network device, the IP, and the MAC a line at a time.
and, a lot uglier, with sed:
ifconfig | sed -n '/inet addr:/s/[^:]\+:\(\S\+\).*/\1/p'
Edit:
Wanted to be shorter than the perl version. Still think that the perl version is the best..
The initial version of this command also outputted extra empty lines, so it went like this: 192.168.166.48 127.0.0.1 This happened on Ubuntu, i haven't tested on anything else. Show Sample Output
Shows only IP-addresses of ifconfig except 127.0.0.0/8. I fixed the script to work on more systems and configs short info /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
Shows the interface and the ip-address Show Sample Output
Command is properly working on HP-UX 11.31 Show Sample Output
commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.
Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):
Subscribe to the feed for: