CentOS脚本获取当前内网IP

[root@AlexWong /]# hostname -I | awk -F " " '{printf $1}'
192.168.0.16

脚本

[root@AlexWong mnt]# cat test.sh
#!/bin/bash
IP=$(hostname -I | awk -F " " '{printf $1}')
echo $IP
[root@AlexWong mnt]# sh test.sh
192.168.0.16

猜你喜欢

转载自blog.csdn.net/qq_26003101/article/details/113551948