You're viewing a comment by schemer and its responses.

schemer Permalink
July 29, 2009, 17:05

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

(why do I need your e-mail?)

(Your twitter name, if you have one. (I'm @pkrumins, btw.))

Type the word "lcd": (just to make sure you're a human)

Please preview the comment before submitting to make sure it's OK.