linux shell获得本机ip地址

IP=`/sbin/ifconfig  | grep  'inet addr:' | grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'`;

编程技巧