可以使用以下命令获取inet的IP地址:

ifconfig eth0 | grep "inet " | awk '{print $2}'

其中,ifconfig eth0命令获取eth0网卡的信息,grep "inet "命令过滤出inet开头的行,awk '{print $2}'命令输出第二列即为IP地址。

centos7eth0 flags=4163UPBROADCASTRUNNINGMULTICAST mtu 1400 inet 17216010 netmask 2552552550 broadcast 172160255 inet6 fe802200fffeed1794 prefixlen 64 scopeid 0x20link ether 0

原文地址: https://www.cveoy.top/t/topic/cEj8 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录