shell獲取當前裝置的IP

2021-09-02 18:38:26 字數 874 閱讀 2320

eth0      link encap:ethernet  hwaddr xx:xx:xx:xx:xx:xx  

inet addr:10.1.35.10 bcast:10.1.35.255 mask:255.255.255.0

inet6 addr: 2001:470:8287:305:250:56ff:fe8d:114e/64 scope:global

inet6 addr: fe80::250:56ff:fe8d:114e/64 scope:link

up broadcast running multicast mtu:1500 metric:1

rx packets:1201477140 errors:0 dropped:0 overruns:0 frame:0

tx packets:713670131 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1000

rx bytes:608033544654 (566.2 gib) tx bytes:138947042948 (129.4 gib)

就是為了把上面的10.1.35.10提取出來。

用下面的shell指令:

ifconfig eth0|grep "inet addr"|awk ''
可以取出如下內容:

addr:10.1.35.10
只需通過冒號(:)分割,取出第二個就可以了,最終的shell指令如下:

ifconfig eth0|grep "inet addr"|awk ''|awk -f: ''

獲取iOS裝置當前ip位址

第一種方法是用系統api的方式獲取,如下 include include include include include include include include include include include include include include include getaddres...

獲取iOS裝置當前ip位址

第一種方法是用系統api的方式獲取,如下 include include include include include include include include include include include include include include include getaddres...

獲取iOS裝置當前ip位址

第一種方法是用系統api的方式獲取,如下 include include include include include include include include include include include include include include include getaddres...