正则表达式打印本机IP地址

方法1:sed查询打印

[root@Linux9 ~]# ifconfig eth0 |grep "inet addr:" |sed 's/Bcast.*$//'g |sed 's/.*://g'
192.168.25.57

方法2:awk查询打印

[root@Linux9 ~]# ifconfig eth0 |grep "inet addr:" |sed 's/Bcast.*$//'g |awk -F ":" {'print $2'}
192.168.25.57


你可能感兴趣的:(正则表达式打印本机IP地址)