[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Get the ip address without using "root"?



Steve Kemp <skx@debian.org> writes:

> /sbin/ifconfig eth0 | grep "inet addr"  | awk  '{print $2}'| awk -F: '{print $2}'

awk can select the line and do the double split in one go:

/sbin/ifconfig eth0 | awk '($0 ~ /^ +inet addr:/) { split($2, a, ":"); print a[2] }'

-- 
  ,''`.
 : :' :        Romain Francoise <rfrancoise@debian.org>
 `. `'         http://people.debian.org/~rfrancoise/
   `-



Reply to: