1. 程式人生 > >shell正則比配IP

shell正則比配IP

bar bash egrep nbsp als root 正則匹配 cat toolbar

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


shell正則比配IP