ifconfig取网络接口列表及ip地址

发布时间:2021-08-03 22:12:33 阅读:1497次
root@test:/home/test/shell# ifconfig |cut -c 1,2,3,4,5,6|tr -d ' '|tr -s '\n'
eth0
lo
wlan0
 
取得ip地址
root@test:/home/test/shell# ifconfig|grep -P 'inet 地址:'
          inet 地址:127.0.0.1  掩码:255.0.0.0
          inet 地址:192.168.6.100  广播:192.168.6.255  掩码:255.255.255.0
root@test:/home/test/shell# ifconfig|grep -P 'inet 地址:[^ ]'
          inet 地址:127.0.0.1  掩码:255.0.0.0
          inet 地址:192.168.6.100  广播:192.168.6.255  掩码:255.255.255.0
root@test:/home/test/shell# ifconfig|grep -P 'inet 地址:[^ ]*'
          inet 地址:127.0.0.1  掩码:255.0.0.0
          inet 地址:192.168.6.100  广播:192.168.6.255  掩码:255.255.255.0
root@test:/home/test/shell# ifconfig|grep -P 'inet 地址:[^ ]*'
          inet 地址:127.0.0.1  掩码:255.0.0.0
          inet 地址:192.168.6.100  广播:192.168.6.255  掩码:255.255.255.0
root@test:/home/test/shell# ifconfig|grep -P 'inet 地址:[^ ]*'|grep "[0-9]"
          inet 地址:127.0.0.1  掩码:255.0.0.0
          inet 地址:192.168.6.100  广播:192.168.6.255  掩码:255.255.255.0
root@test:/home/test/shell# ifconfig|grep -P 'inet 地址:[^ ]*'|grep "[0-9.]"
          inet 地址:127.0.0.1  掩码:255.0.0.0
          inet 地址:192.168.6.100  广播:192.168.6.255  掩码:255.255.255.0
root@test:/home/test/shell# ifconfig|grep -P 'inet 地址:[^ ]*'|grep "[0-9.]*"
          inet 地址:127.0.0.1  掩码:255.0.0.0
          inet 地址:192.168.6.100  广播:192.168.6.255  掩码:255.255.255.0
root@test:/home/test/shell# ifconfig|grep -P 'inet 地址:[^ ]*'|grep -o "[0-9.]*"
127.0.0.1
255.0.0.0
192.168.6.100
192.168.6.255
255.255.255.0
root@test:/home/test/shell# ifconfig|grep -P 'inet 地址:[^ ]*'|grep -o "[0-9.]*"
127.0.0.1
255.0.0.0
192.168.6.100
192.168.6.255
255.255.255.0
root@test:/home/test/shell# ifconfig wlan0|grep -P 'inet 地址:[^ ]*'|grep -o "[0-9.]*"
192.168.6.100
192.168.6.255
255.255.255.0
root@test:/home/test/shell# ifconfig wlan0|grep -P 'inet 地址:[^ ]*' -o|grep -o "[0-9.]*"
192.168.6.100
 

如有问题,可以QQ搜索群1028468525加入群聊,欢迎一起研究技术

支付宝 微信

有疑问联系站长,请联系QQ:QQ咨询
上一篇:shell相关统计
下一篇:php计数器

转载请注明:ifconfig取网络接口列表及ip地址 出自老鄢博客 | 欢迎分享