使用ifconfig取出网卡eth0的ip地址
生活随笔
收集整理的這篇文章主要介紹了
使用ifconfig取出网卡eth0的ip地址
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
方法1:sed命令
| 12 | [root@oldboyedu?~]#?ifconfig?eth0?|sed?-n?'2p'?|sed's#^.*addr:##g'|sed?'s#??B.*$##g'10.0.0.50 |
方法2:cut
| 12 | [root@oldboyedu?~]#?ifconfig?eth0|grep?'inetaddr'|cut?-d?":"?-f2|cut?-d?"?"?-f110.0.0.50 |
方法3:普通awk?使用2遍
| 12 | [root@oldboyedu?~]#?ifconfig?eth0|grep?'inet?addr'|awk?-F?":"?'{print?$2}'|awk?'{print?$1}'10.0.0.50 |
方法4:awk同時多分隔符法
| 12 | [root@oldboyedu?~]#?ifconfig?eth0|grep?'inetaddr'|awk?-F?'[?:]'?'{print?$13}'10.0.0.50 |
方法5:awk同時多分隔符法
| 1234 | [root@oldboyedu?~]#?ifconfig?eth0|sed?-n?'2p'|awk-F?'[?:]+'?'{print?$4}'10.0.0.50[root@oldboyedu?~]#?ifconfig?eth0?|awk?-F'[?:]+'?'NR==2?{print?$4}'10.0.0.50 |
方法6:sed(正則)
| 12 | [root@oldboyedu?~]#?ifconfig?eth0?|sed?-nr?'2s#^.*dr:(.*)??B.*$#\1#gp'??????????10.0.0.50 |
方法7:grep-perl正則方法
| 12 | [root@show?~]#?ifconfig?eth0|grep?-Po?'(?<=dr:)[0-9.]+'10.0.0.50 |
轉載自http://lidao.blog.51cto.com/3388056/1911571
轉載于:https://blog.51cto.com/2690403167/1966440
總結
以上是生活随笔為你收集整理的使用ifconfig取出网卡eth0的ip地址的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 的内怎么放_放了心脏支架能活多久?医生坦
- 下一篇: centos后台登录ftp_「vscod