文章目录
1. 使用NR行号来定位提取IP
[root@ecs-c13b awk]# ifconfig eth0 |awk -F " " 'NR==2{print $2}'
192.168.0.192
2. 去除首行
[root@ecs-c13b awk]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.0.1 0.0.0.0 UG 100 0 0 eth0
169.254.169.254 192.168.0.1 255.255.255.255 UGH 10