获取IP地址bash[转载]

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

原文地址:https://www.cnblogs.com/paul8339/p/4867525.html