文本三剑客之sed,提取IP地址


Sed网卡取IP

 

[root@centos8 ~]#ifconfig ens160|sed  -n '2p'|sed 's/^.*inet //'|sed 's/ .*//'  

 

[root@centos8 ~]#ifconfig ens160|sed  -rn '2s/^([^0-9]+)([0-9.]+)( .*)$/\2/p'      

 

[root@centos8 ~]#ifconfig ens160|sed  -rn '2s/^[^0-9]+([0-9.]+) .*$/\1/p'  

 

=ifconfig |sed  -rn "2s/[^0-9]+([0-9.]+) .*$/\1/p"  

 

#ifconfig |sed -n '2s/^.*inet //;s/netmask.*//p'

 

#ifconfig |sed -n '2s/^.*inet //p' |sed -n 's/netmask.*//p'

 

#ifconfig |sed -En '2s/^[^0-9]+([0-9.]+).*$/\1/p'

 

#ifconfig |sed -nr '2s/^[^0-9]+([0-9.]{7,15}).*/\1/p'

 

#ifconfig |sed -nE '2s/[^0-9]+([0-9.]+).*/\1/p'

 

#ifconfig |sed -nr '2s/[^0-9]+([0-9.]+).*/\1/p'

 

#ifconfig eth0 |sed -nr '2s/(.*inet) ([0-9].*) (netmask.*)/\2/p'

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM