shell正则比配IP

时间:2018-01-12 17:40:54   收藏:0   阅读:229
shell的正则匹配IP

[root@master ~]# cat test.txt 
2014-08-17
20140907
14 03 22
aa.aa.bb.cc
af.23.67.90
ffffff
oo.09.0f.87.90
192.168.1.2
121.168.2.3
0987238349
999.999.99.999
123-212-2-3

用grep

[root@master ~]# egrep "((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)"  test.txt 
192.168.1.2
121.168.2.3


原文:http://blog.51cto.com/853056088/2060330

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!