linux中使用文本工具截取ip 的几种方法
生活随笔
收集整理的這篇文章主要介紹了
linux中使用文本工具截取ip 的几种方法
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
linux中使用文本工具截取ip 的幾種方法
1,使用awk工具
[root@mycentos?data]#?ifconfig?ens33 ens33:?flags=4163<UP,BROADCAST,RUNNING,MULTICAST>??mtu?1500inet?192.168.1.140??netmask?255.255.255.0??broadcast?192.168.1.255inet6?fe80::8abb:80e7:a0ad:6463??prefixlen?64??scopeid?0x20<link>ether?00:0c:29:52:25:a4??txqueuelen?1000??(Ethernet)RX?packets?53417??bytes?5526762?(5.2?MiB)RX?errors?0??dropped?0??overruns?0??frame?0TX?packets?4618??bytes?627215?(612.5?KiB)TX?errors?0??dropped?0?overruns?0??carrier?0??collisions?0 [root@mycentos?data]#?ifconfig?|awk?-F?"?"??'NR==2?{print?$2}' 192.168.1.140
2,使用sed工具
1)
[root@mycentos?data]#?ifconfig?ens33 ens33:?flags=4163<UP,BROADCAST,RUNNING,MULTICAST>??mtu?1500inet?192.168.1.140??netmask?255.255.255.0??broadcast?192.168.1.255inet6?fe80::8abb:80e7:a0ad:6463??prefixlen?64??scopeid?0x20<link>ether?00:0c:29:52:25:a4??txqueuelen?1000??(Ethernet)RX?packets?53417??bytes?5526762?(5.2?MiB)RX?errors?0??dropped?0??overruns?0??frame?0TX?packets?4618??bytes?627215?(612.5?KiB)TX?errors?0??dropped?0?overruns?0??carrier?0??collisions?0 [root@mycentos?data]#?ifconfig?|sed?-n?"2p"|sed?'s#^.*net?##g'|sed?'s#?net.*$##g' 192.168.1.140? [root@mycentos?data]#2)
[root@mycentos?data]#?ifconfig?ens33 ens33:?flags=4163<UP,BROADCAST,RUNNING,MULTICAST>??mtu?1500inet?192.168.1.140??netmask?255.255.255.0??broadcast?192.168.1.255inet6?fe80::8abb:80e7:a0ad:6463??prefixlen?64??scopeid?0x20<link>ether?00:0c:29:52:25:a4??txqueuelen?1000??(Ethernet)RX?packets?53417??bytes?5526762?(5.2?MiB)RX?errors?0??dropped?0??overruns?0??frame?0TX?packets?4618??bytes?627215?(612.5?KiB)TX?errors?0??dropped?0?overruns?0??carrier?0??collisions?0 [root@mycentos?data]#?ifconfig?|sed?-n?"2p"|sed?'s#^.*net?##g'|sed?'s#?net.*$##g' 192.168.1.140? [root@mycentos?data]#?歡迎大家留意討論?相互學習?我一直在
轉(zhuǎn)載于:https://blog.51cto.com/1167248/2132389
總結(jié)
以上是生活随笔為你收集整理的linux中使用文本工具截取ip 的几种方法的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: CVPR!你凭什么收录我3篇论文!?
- 下一篇: hadoop rebalance