Linux 之 正則實踐
阿新 • • 發佈:2018-05-10
正則實踐正則實踐
1.通過awk獲取IP地址 [root@localhost ~]# ifconfig eth2 | grep inet inet addr:10.3.151.25 Bcast:10.3.151.255 Mask:255.255.255.0 inet6 addr: fe80::250:56ff:fe80:6e7e/64 Scope:Link [root@localhost ~]# ifconfig eth2 | grep "\binet\b" inet addr:10.3.151.25 Bcast:10.3.151.255 Mask:255.255.255.0 [root@localhost ~]# ifconfig eth2 | grep "\binet\b" | awk ‘{print $0}‘ inet addr:10.3.151.25 Bcast:10.3.151.255 Mask:255.255.255.0 [root@localhost ~]# ifconfig eth2 | grep "\binet\b" | awk ‘{print $2}‘ addr:10.3.151.25 [root@localhost ~]# ifconfig eth2 | grep "\binet\b" | awk ‘{print $2}‘| awk -F ‘:‘ ‘{print $2}‘ 10.3.151.25
Linux 之 正則實踐