zoukankan      html  css  js  c++  java
  • ifconfig eth0 取行取列

    [root@xusx xusx]# ifconfig eth0
    eth0      Link encap:Ethernet  HWaddr 00:0C:29:9A:CD:B1 
              inet addr:192.168.138.138  Bcast:192.168.138.255  Mask:255.255.255.0
              inet6 addr: fe80::20c:29ff:fe9a:cdb1/64 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:68094 errors:0 dropped:0 overruns:0 frame:0
              TX packets:41042 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000
              RX bytes:28601665 (27.2 MiB)  TX bytes:5618664 (5.3 MiB)

    第一种

    [root@xusx ~]# ifconfig eth0|awk -F "[: ]+" 'NR==2{print $4}'
    192.168.138.138

    第二种

    [root@xusx ~]# ifconfig eth0|sed -n '2p'|sed -r 's#(^.*r:)|(Bc.*$)##g'
    192.168.138.138

    [root@xusx ~]# ifconfig eth0|sed -nr '2s#^.*r:| Bc.*$##gp'
    192.168.138.138

    第三种

    [root@xusx ~]# ifconfig eth0|egrep -o "inet addr:[0-9.]*"
    inet addr:192.168.138.138
    [root@xusx ~]# ifconfig eth0|egrep -o "inet addr:[0-9.]*"|egrep -o "[0-9.]*"
    192.168.138.138

    第四种

    [root@xusx ~]# ifconfig eth0 |awk 'NR==2'
              inet addr:192.168.138.136  Bcast:192.168.138.255  Mask:255.255.255.0
    [root@xusx ~]# ifconfig eth0 |awk 'NR==2'|cut -d ":" -f2
    192.168.138.136 Bcast
    [root@xusx ~]# ifconfig eth0 |awk 'NR==2'|cut -d ":" -f2|cut -d " " -f1
    192.168.138.136

  • 相关阅读:
    jquery图片播放弹出插件Fancybox
    D3js-API介绍【英】
    ZOJ 3156 Taxi (二分匹配+二分查找)
    linux权限之su和sudo的差别
    CareerCup之1.6 Rotate Image
    [oracle]pl/sql --分页过程demo
    已迁移到http://www.coffin5257.com
    C# 之 集合ArrayList
    Java 序列化Serializable具体解释(附具体样例)
    Android 短信验证码控件
  • 原文地址:https://www.cnblogs.com/xusx/p/6093411.html
Copyright © 2011-2022 走看看