[olug] Unix Tip: GET YOUR IP-ADDRESS, Omaha Perl Mongers

Jay Hannah jay at jays.net
Fri Mar 21 13:41:37 UTC 2003


Unix Guru Universe said:
> Type this simple command at the unix-prompt
> ifconfig | grep "inet addr" |  grep -v "127.0.0.1" | awk '{print $2;}' | awk -F':' '{print $2;}'

David Walker wrote:
> If a user wished to know their IP address they can simply type ifconfig

CM Miller wrote:
> If they have an internet connection, then point browser to http://whatismyip.com/

--- Vincent <vincentr at cox.net> wrote:
> The cookie is yours!


Perl Monger solution:

ifconfig | perl -ne '/dr:(\S+)/||next;(/127\.0\.0\.1/)||print"$1\n"'

Density is good. I'm hoping to win one of the cookies Vincent mentioned
in under an hour of labor. -grin-

In addition to making the world a far better place by authoring yet
another craptastic filter for ifconfig output, I thought I'd go into
shameless self-promotion mode and mention that the Omaha Perl Mongers
have a new website:

   http://omaha.pm.org/

Join our mailing list and come to our first meeting in years, to be held
April 1! Drink some beer, learn some Perl. You know you want some
software on that beefy server of yours. Perl is here for you. It can do
anything*.

Linus called me and specifically said *you* should join our list and
come to our meeting. Don't let him down. -grin-

Jay Hannah
freshly knighted omaha.pm.org group leader
http://omaha.pm.org/

* World peace not included.


More information about the OLUG mailing list