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

  • 相关阅读:
    Solr6.6环境安装及core的创建(win7环境)
    使用Druid作为数据源
    Windows远程数据同步工具cwRsync
    解读zookeeper的配置项
    堵塞与非堵塞原理
    Apache Hadoop2.0之HDFS均衡操作分析
    转到简书去了
    淘宝技术这十年概要
    Facebook广告API系列 Business Manager
    Facebook广告API系列 3 Ads Management
  • 原文地址:https://www.cnblogs.com/xusx/p/6093411.html
Copyright © 2011-2022 走看看