shell脚本过滤得到centos7的ip地址

[root@bogon backup]# ip a show dev ens33
2: ens33:  mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 1000
    link/ether 00:0c:29:00:cb:5d brd ff:ff:ff:ff:ff:ff
    inet 192.168.13.140/24 brd 192.168.13.255 scope global ens33
       valid_lft forever preferred_lft forever
    inet6 fe80::d7fe:e777:da68:c4d6/64 scope link 
       valid_lft forever preferred_lft forever
[root@bogon backup]# ip a show dev ens33|grep -w inet|awk '{print $2}'|sed 's/\/.*//'
192.168.13.140   

或者

[root@bogon backup]# ip a show dev ens33|grep -w inet|awk '{print $2}'|awk -F '/' '{print $1}'
192.168.13.140


你可能感兴趣的:(CentOS7)