Alexander Skwar wrote:
Don't like that - there might be locales, where there's no "inet"
in the line. IMO better:
/sbin/ifconfig eth0 | grep :255\. | cut -d : -f 2 | cut -d ' ' -f 1

broadcasts don't always begin or end with 255, odd yes, but if we're spliting hairs then anything is possible.

The only option is to assume that the address line appears on the 2nd line, and it is delimited by a colon, and then strip out the fields past the trailing spaces.

/sbin/ifconfig eth0 | head -n 2 | tail -n 1 | cut -d : -f 2 | cut -d ' ' -f 1

and.. of course, this only works in linux... and for IPv4 Addresses.
--
gentoo-user@gentoo.org mailing list

Reply via email to