shell脚本获取当前ip地址



需求
shell脚本里我需要根据不同的ip地址做出不同的操作,因此我需要在shell脚本里获取当前主机的ip地址
  www.2cto.com  
 
我需要获取到192.168.1.111这个ip地址
  www.2cto.com  
方法1
[html] 
 
ifconfig |grep 'inet 地址'|grep '192.168.1' | grep -v 'grep' | awk '{print $2}'| tr -d "地址:"  
效果

相关内容

    暂无相关文章