利用grep与cut只显示IP地址

来源:互联网 发布:建筑工程设计优化方法 编辑:程序博客网 时间:2024/06/16 09:18

[root@localhost ~]# echo "This is IP = $(ifconfig | grep -o 'inet addr:[^[:space:]]*' | cut -d: -f2 | grep -v '127.0.0.1')"

显示结果为:This is IP = x.x.x.x

0 0
原创粉丝点击