一般我们使用ifconfig查看网卡信息,请问你可以通过什么命令,让其只输出IP地址?


[root@DB-Server ~]# ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 00:0C:29:9E:70:0E
          inet addr:192.168.50.128  Bcast:192.168.42.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe9e:700e/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:135 errors:0 dropped:0 overruns:0 frame:0
          TX packets:216 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:14062 (13.7 KiB)  TX bytes:26007 (25.3 KiB)


[root@DB-Server ~]# ifconfig eth0 | grep "inet addr"
          inet addr:192.168.50.128  Bcast:192.168.42.255  Mask:255.255.255.0


[root@DB-Server ~]# ifconfig eth0 | grep "inet addr" | awk '{ print $2}'
 
addr:192.168.50.128
 
[root@DB-Server ~]# ifconfig eth0 | grep "inet addr" | awk '{ print $2}' | awk -F: '{print $2}'
 
192.168.50.128