我怎样才能只获得 IP 以及它是哪个接口 IP?这样我就可以保留记录文件,例如 realtime.ini
1 - 测试.sh
#!/bin/bash
ipstring ='inet (.*)'
for i in $(ip addr);
do
echo $i #on found it write down to my realtime.ini as a list for future query
done
2 - 实时.ini
em1,192.168.1.2
lo,127.0.0.1
wlan0,<not found>
跟进:仅针对单个 ip:$ ifconfig eth0 | grep 'inet 地址:' | 切-d:-f2 | awk '{ 打印 $1}' 192.168.1.2