Script help

Jacques B. jjrboucher at gmail.com
Tue Feb 12 16:59:04 UTC 2008


<snip>
>
> People love to use very long pipelines. How about...
>
> ifconfig eth0 | awk -F. '/inet addr:/ {print $3}'

Or if the NIC is not necessarily eth0, but it's still the first one,
then the below will still work and will exclude any subsequent NICs
(you beat me to it, I was just testing things out before posting...).

ifconfig | awk -F . 'NR==1, /inet addr/ {printf $3}'

Jacques B.




More information about the fedora-list mailing list