shell正则匹配ip(学习shell笔记七)

来源:互联网 发布:pdf 安卓 知乎 编辑:程序博客网 时间:2024/06/18 15:26

[root@localhost ~]# vim test.txt





2014-08-17
20140907
14 03 22



192.168.1.2
121.168.2.3

123-212-2-3

[root@localhost ~]# grep "[0-9]\{1,3\}[.][0-9]\{1,3\}[.][0-9]\{1,3\}[.][0-9]\{1,3\}" test.txt
192.168.1.2
121.168.2.3

[root@localhost ~]# grep "[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}" test.txt
192.168.1.2
121.168.2.3



原创粉丝点击