标签:linux
法一
root@test ~$eval `ifconfig | sed -rn ‘/^[^ \t]/{N;s/(^[^ ]*).*addr:([^ ]*).*/\1 \2/p}‘ | awk ‘$2!~/^127|^0|^$/{print $1"="$2}‘|head -1`
root@test ~$
root@test ~$
root@test ~$echo $eth0
10.240.210.131
法二
root@test ~$echo `ifconfig | sed -rn ‘1,2‘p | awk ‘{print $2}‘ | awk -F "addr:" ‘{print $2}‘ |sed /^\s*$/d`
10.240.210.131
标签:linux
原文地址:http://xoyabc.blog.51cto.com/7401264/1662198