23 characters
The 'g' matches in the word 'global', the scope value of the address, which is not on the line with the loopback address. As a bonus with this style, you also get the CIDR mask of the net.
Even better:
ipa(){ ip a|awk '/g/{print$2}';}
Then you can type 'ipa' anytime you want. Put it in .bashrc for persistence. Name it 'i' instead and you have a one character command to get your IP address.
I am being sponsored by Syntress! They bought me an amazing dedicated server to run catonmat on. If you're looking web services, I highly recommend the Syntress guys!
Education Sponsors
I am being sponsored by A-Writer! If you ever need help with essay writing, look no further than A-Writer! They will help you with your writing in as quickly as 3 hours!
bash on Ubuntu 8.04:
ip a|awk '/g/{print$2}'23 characters
The 'g' matches in the word 'global', the scope value of the address, which is not on the line with the loopback address. As a bonus with this style, you also get the CIDR mask of the net.
Even better:
ipa(){ ip a|awk '/g/{print$2}';}Then you can type 'ipa' anytime you want. Put it in .bashrc for persistence. Name it 'i' instead and you have a one character command to get your IP address.
Reply To This Comment