[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
本文通过使用Linux命令行工具vim创建了一个包含多个IP地址的文本文件,并演示了如何利用grep命令精确匹配并提取这些IP地址。
1442

被折叠的 条评论
为什么被折叠?



