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

  • 相关阅读:
    Mybatis 接口绑定
    Spring AOP
    Spring 基础使用
    Java 类的生命周期
    Mybatis 测试延迟加载
    Mybatis
    eclipse 常用jar包总结
    Web 过滤器参数设置问题
    Web 单元测试
    zabbix监控-自定义监控与报警(二)
  • 原文地址:https://www.cnblogs.com/xusx/p/6093411.html
Copyright © 2011-2022 走看看