[root@Linux9~]#ifconfigeth0|grep"inetaddr:"|sed's/Bcast.*$//'g|sed's/.*://g' 192.168.25.57
[root@Linux9~]#ifconfigeth0|grep"inetaddr:"|sed's/Bcast.*$//'g|awk-F":"{'print$2'} 192.168.25.57
方法3:cut分段打印
[root@Linux9~]#ifconfigeth0|grep'Bcast'|cut-d':'-f3|cut-d""-f1 192.168.31.255
[root@Linux9~]#ifconfigeth0|grep'Mask'|awk-F:'{print$4}' 255.255.240.0原文链接:https://www.f2er.com/regex/359551.html