记录学习过程中的点点滴滴
2012年五月
linux通过Shell获得本机ip地址方法
五 31st
通过Shell获得本机IP地址方法,直接上代码:
IP=`ifconfig | grep 'inet addr:' | grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'`; echo $IP;
如果想获得第一个IP地址的话,可以在grep ‘inet addr:’增加参数-m 1即可
记录学习过程中的点点滴滴
五 31st
通过Shell获得本机IP地址方法,直接上代码:
IP=`ifconfig | grep 'inet addr:' | grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'`; echo $IP;
如果想获得第一个IP地址的话,可以在grep ‘inet addr:’增加参数-m 1即可
近期评论