Need help from the sed gods

Antony Stone Antony at
Sun Sep 22 05:19:22 PDT 2002

On Sunday 22 September 2002 1:12 pm, Oliver Brakmann wrote:

> Hi group,
> I need a little help:
> I want to extract the IP address of a running network interface
> from the output of 'ifconfig $interface'.
> I get as far as 'ifconfig $interface | head -2 | tail -1 | sed ...'
> Can anybody tell me which sed expression I have to use to get
> the IP address?

Instead of using sed, which is a bit overkill just for this, try tr and cut:

ifconfig $interface | head -2 | tail -1 | tr -s ' :' ' ' | cut -d' ' -f4

(That's a space and a colon between the first pair of quotes, a space between 
the second pair, and a space betwen the third pair.)



The difference between theory and practice is that
in theory there is no difference, whereas in practice there is.
Unsubscribe: send email to listar at
and put 'unsubscribe lfs-chat' in the subject header of the message

More information about the lfs-chat mailing list