Show interface/ip using awk

ifconfig -a| awk '/^wlan|^eth|^lo/ {;a=$1;FS=":"; nextline=NR+1; next}{ if (NR==nextline) { split($2,b," ")}{ if ($2 ~ /[0-9]\./) {print a,b[1]}; FS=" "}}'
Interfaces like lo can be omitted from the beginning, there are probably better ways of doing this, i'm a noob at awk.
Sample Output
lo 127.0.0.1
wlan0 192.168.1.100

5
By: alf
2010-04-15 04:34:28

What Others Think

Doesn't matter if you're a "noob". At least you tried. And if someone comes up with a better way, we all learn from it. Keep it up!
SuperFly · 601 weeks and 2 days ago
This article is an appealing wealth of informative data that is interesting and well-written. I commend your hard work on this and thank you for this information. You’ve got what it takes to get attention. disposable face mask
KayGasaway · 3 weeks and 5 days ago
I can see that you are an expert at your field! I am launching a website soon, and your information will be very useful for me.. Thanks for all your help and wishing you all the success in your business. l arginine side effects
KayGasaway · 3 weeks and 4 days ago
I think this is a really good article. You make this information interesting and engaging. You give readers a lot to think about and I appreciate that kind of writing. ??
KayGasaway · 3 weeks and 1 day ago
nice post, keep up with this interesting work. It really is good to know that this topic is being covered also on this web site so cheers for taking time to discuss this! ??
KayGasaway · 2 weeks and 3 days ago
security and safety with care from staff 24 hours a day with professional supervision on online gambling gambling, legal gambling websites The best football betting website, quick deposit and withdrawal, many promotions, football betting, slots, lottery, baccarat, the number 1 online casino, must be 789Bet and 789Betting 123bet line
KayGasaway · 6 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

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.

Share Your Commands



Stay in the loop…

Follow the Tweets.

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

Subscribe to the feeds.

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: