Gentoo Archives: gentoo-user

From: Billy Holmes <billy@××××××.net>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] file with IP?
Date: Fri, 04 Nov 2005 19:47:06
Message-Id: 436BBA67.4090607@gonoph.net
In Reply to: Re: [gentoo-user] file with IP? by Alexander Skwar
1 Alexander Skwar wrote:
2 > Don't like that - there might be locales, where there's no "inet"
3 > in the line. IMO better:
4 > /sbin/ifconfig eth0 | grep :255\. | cut -d : -f 2 | cut -d ' ' -f 1
5
6 broadcasts don't always begin or end with 255, odd yes, but if we're
7 spliting hairs then anything is possible.
8
9 The only option is to assume that the address line appears on the 2nd
10 line, and it is delimited by a colon, and then strip out the fields past
11 the trailing spaces.
12
13 /sbin/ifconfig eth0 | head -n 2 | tail -n 1 | cut -d : -f 2 | cut -d ' '
14 -f 1
15
16 and.. of course, this only works in linux... and for IPv4 Addresses.
17 --
18 gentoo-user@g.o mailing list

Replies

Subject Author
Re: [gentoo-user] file with IP? Arturo 'Buanzo' Busleiman <buanzo@××××××××××.ar>
Re: [gentoo-user] file with IP? Alexander Skwar <listen@×××××××××××××××.name>