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 |