egrep过滤ip地址的正则表达式

Shell Liemer_Lius 1020℃ 0评论

ip地址的正则相对比较长,难度倒是不大,如下:

$ ifconfig -a |egrep --color -o '\<([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\>\.\<([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\>\.\<([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\>\.\<([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\>'
10.141.14.85
10.141.63.255
255.255.192.0
127.0.0.1
255.0.0.0

以上就是ifconfig以后的正则过滤ip地址的方法和结果,牢记即可。

转载请注明:liutianfeng.com » egrep过滤ip地址的正则表达式

喜欢 (1)

发表回复