Get your local/private IP

localIP() { ifconfig ${1:--a} | sed '/Link encap\|inet\|6 addr/!d;s/Link encap.*$//;s/.*inet addr:\([0-9\.]*\).*/\1/g;s/.*inet6 addr: \(.*\) .*/\1/g' ; }
If you don't send an interface, it shows private IP address of all interfaces

-2
By: vando
2011-03-20 04:59:54

What Others Think

That is not local/private IP. This script is a mess. The output of ifconfig is locale-dependent. Use "ip" instead.
6bc98f7f · 558 weeks and 5 days ago
I am happy to find this post very useful for me, as it contains lot of information. I always prefer to read the quality content and this thing I found in you post. Thanks for sharing. medical face mask
KayGasaway · 10 weeks and 2 days ago
This was really an interesting topic and I kinda agree with what you have mentioned here! l arginine
KayGasaway · 10 weeks and 2 days ago
Thanks for providing recent updates regarding the concern, I look forward to read more. ???????
KayGasaway · 9 weeks and 6 days ago
Merely a smiling visitant here to share the love (:, btw outstanding style. places to eat near me
KayGasaway · 9 weeks and 4 days ago
A great content material as well as great layout. Your website deserves all of the positive feedback it’s been getting. I will be back soon for further quality contents. nearest breakfast
KayGasaway · 9 weeks and 3 days ago
I read that Post and got it fine and informative. ????????????????
KayGasaway · 9 weeks and 3 days ago
I would like to thank you for the efforts you have made in writing this article. I am hoping the same best work from you in the future as well. Thanks... http://www.bookofhook.com/phpBB/viewtopic.php?t=379741">visit our website
KayGasaway · 9 weeks and 2 days ago
Make sure that you can afford to devote this much floor space to your bed. Otherwise, you might have to settle for something smaller. fleet mattress
KayGasaway · 9 weeks and 1 day ago
Your work is very good and I appreciate you and hopping for some more informative posts. Thank you for sharing great information to us. ??
KayGasaway · 9 weeks and 1 day ago
I really impressed after read this because of some quality work and informative thoughts . I just wanna say thanks for the writer and wish you all the best for coming!. fiber laser ??????
KayGasaway · 9 weeks ago
Great job for publishing such a beneficial web site. Your web log isn’t only useful but it is additionally really creative too. There tend to be not many people who can certainly write not so simple posts that artistically. Continue the nice writing ?????
KayGasaway · 8 weeks and 5 days ago
Online baccarat, which website is good to apply for baccarat, which website is good here is the answer ??????????? ?????
KayGasaway · 8 weeks and 3 days ago
Wow, What a Excellent post. I really found this to much informatics. It is what i was searching for.I would like to suggest you that please keep sharing such type of info.Thanks onewalmart login
KayGasaway · 8 weeks and 1 day ago
cash for cars Buffalo Are you looking to sell your junk car for cash in Buffalo, NY-Buffalo Junkyard provides the best cash offer with free towing service in Buffalo and surrounding areas. https://bobscashforjunkcarsbuffalony.com/
KayGasaway · 6 weeks and 3 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: