In a message dated: Wed, 24 Oct 2001 13:03:01 EDT
Benjamin Scott said:

>ifconfig $IFACE | perl -ne 'print "$1\n" if m/inet addr:([0-9.]*)/;'
>
>  (or something like it) is what I usually use.

Or another variation on the same theme without the overhead of perl:

        ifconfig eth0 | grep inet | awk -F: '{print $2}' | cut -f1 -d' '

Though I think Ben's idea is actually faster:

        $ time ifconfig eth0 | grep inet | awk -F: '{print $2}' | cut -f1 -d' '
        10.1.8.94

        real    0m0.021s
        user    0m0.000s
        sys     0m0.010s

        $ time ifconfig eth0 | perl -ne 'print "$1\n" if m/inet addr:([0-9.]*)/;'
        10.1.8.94

        real    0m0.015s
        user    0m0.000s
        sys     0m0.010s

You can tighten this up a little too:

        ifconfig eth0 | perl -ne 'print "$1\n" if /addr:([0-9.]*)/;'

but all it saves are a couple keystrokes :)

-- 

Seeya,
Paul
----

                          God Bless America!

        ...we don't need to be perfect to be the best around,
                and we never stop trying to be better. 
                       Tom Clancy, The Bear and The Dragon



**********************************************************
To unsubscribe from this list, send mail to
[EMAIL PROTECTED] with the following text in the
*body* (*not* the subject line) of the letter:
unsubscribe gnhlug
**********************************************************

Reply via email to