Shell获取IP

来自linux中国网wiki
跳到导航 跳到搜索

intra ip

Sed skill

[evan@prod-core-mongo ~]$ sudo ip a | grep eth0| awk '{print $2}'
eth0:
172.16.0.40/20
[evan@prod-core-mongo ~]$ sudo ip a | grep eth0| awk '{print $2}'|sed -n  '2p'
172.16.0.40/20
[evan@prod-core-mongo ~]$ sudo ip a | grep eth0| awk '{print $2}'|sed -n  '2p'|awk -F'/' '{print $1}'
172.16.0.40


blog.linuxchina.net 让ifconfig更清爽些