标签:正则实践
正则实践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
标签:正则实践
原文地址:http://blog.51cto.com/12965094/2115003