junjie 通过本文主要向大家介绍了shell脚本,shell脚本编程,shell脚本学习指南,shell脚本实例,linux shell脚本等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
方法一:
/sbin/ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print $2}'|tr -d "addr:"
or
/sbin/ifconfig|sed -n '/inet addr/s/^[^:]*:\([0-9.]\{7,15\}\) .*/\1/p'
</div>
方法二:
local_host="`hostname --fqdn`"
local_ip=`host $local_host 2>/dev/null | awk '{print $NF}'`
</div>
方法三:
local_host="`hostname --fqdn`"
nslookup -sil $local_host 2>/dev/null | grep Address: | sed '1d' | sed 's/Address://g'
</div>

