码迷,mamicode.com
首页 > 其他好文 > 详细

小方法——匹配ip地址

时间:2019-11-04 09:14:04      阅读:118      评论:0      收藏:0      [点我收藏+]

标签:loopback   地址   overruns   eth0   opp   net   eth1   e30   ram   

[root@MiWiFi-R1CM-srv ~]# ifconfig |sed -n ‘2p‘
          inet addr:192.168.139.128  Bcast:192.168.139.255  Mask:255.255.255.0
[root@MiWiFi-R1CM-srv ~]# ifconfig 
eth0      Link encap:Ethernet  HWaddr 00:0C:29:30:61:2E  
          inet addr:192.168.139.128  Bcast:192.168.139.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe30:612e/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:493 errors:0 dropped:0 overruns:0 frame:0
          TX packets:79 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:52802 (51.5 KiB)  TX bytes:14608 (14.2 KiB)

eth1      Link encap:Ethernet  HWaddr 00:0C:29:30:61:38  
          inet addr:192.168.31.66  Bcast:192.168.31.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe30:6138/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:639734 errors:0 dropped:0 overruns:0 frame:0
          TX packets:306759 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:216599719 (206.5 MiB)  TX bytes:32159081 (30.6 MiB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:226 errors:0 dropped:0 overruns:0 frame:0
          TX packets:226 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:167792 (163.8 KiB)  TX bytes:167792 (163.8 KiB)

[root@MiWiFi-R1CM-srv ~]# ifconfig |sed -n ‘2p‘ | sed -r ‘s#.*r:(.*) B.*k:(.*)#\1 \2#g‘ 
192.168.139.128  255.255.255.0

  

[root@MiWiFi-R1CM-srv ~]# ifconfig | grep -E -o  ‘[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}‘
192.168.139.128
192.168.139.255
255.255.255.0
192.168.31.66
192.168.31.255
255.255.255.0
127.0.0.1
255.0.0.0

  

[root@MiWiFi-R1CM-srv ~]# ifconfig | grep -o  ‘[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}‘
192.168.139.128
192.168.139.255
255.255.255.0
192.168.31.66
192.168.31.255
255.255.255.0
127.0.0.1
255.0.0.0

  

[root@MiWiFi-R1CM-srv ~]# ifconfig |egrep -o "([0-9]{1,3}\.){3}[0-9]{1,3}"
192.168.139.128
192.168.139.255
255.255.255.0
192.168.31.66
192.168.31.255
255.255.255.0
127.0.0.1
255.0.0.0

  

小方法——匹配ip地址

标签:loopback   地址   overruns   eth0   opp   net   eth1   e30   ram   

原文地址:https://www.cnblogs.com/betterquan/p/11790270.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!