zegrep命令是一个文件字符串过滤工具,可以使用zegrep在压缩文件中多次搜索相对应的文件名与内容。
语法格式:zegrep [参数] [文件路径]
常用参数:
-n | 搜索显示行 |
-l | 列出包含多个模式的那些压缩文件的文件名 |
参考实例
使用zegrep过滤linuxprobe.txt中ledlinux字符:
1 |
[root@ledlinux ~]# zegrep "ledlinux" linuxprobe.txt |
使用zegrep搜索压缩文件中的多重模式:
1 |
[root@ledlinux ~]# zegrep 'shah|root|apache' linuxprobe.gz |
使用压缩文件中的-n选项在文件中搜索多个模式以及相关的行号:
1 |
[root@ledlinux ~]# zegrep -n 'shah|root|apache' linuxprobe.gz |
使用-l选项列出包含多个模式的那些压缩文件的文件名:
1 |
[root@ledlinux ~]# zegrep -l 'shah|root|apache' *.gz |