您的位置:首页 > 运维架构 > Linux

获取linux服务器IP

2013-03-11 17:00 225 查看
function get_linux_ip
{
echo "start to read host ip"

if [ -f /home/1.properties ];then
echo "file is exsit"
cd /home
rm -rf 1.properties
cd ..
else
echo "file is not exsit"
cd /home
touch 1.properties
cd ..
fi

echo `/sbin/ifconfig -a | grep inet | grep -v inet6 | awk -F ":" '{print $2}'|awk -F " " '{print $1}'` >> /home/1.properties

echo "end to read host ip  "
}

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  shell