Linux command
zipgrep 命令
网络
复制后可按需替换文件名、目录或参数。
常用示例
Search in ZIP
zipgrep [pattern] [archive.zip]
Search specific file
zipgrep [pattern] [archive.zip] [file.txt]
Case insensitive
zipgrep -i [pattern] [archive.zip]
Show line numbers
zipgrep -n [pattern] [archive.zip]
Count matches
zipgrep -c [pattern] [archive.zip]
List matching files only
zipgrep -l [pattern] [archive.zip]
Search but exclude files in subdirectories
zipgrep [pattern] [archive.zip] *.[ch] -x */*
说明
zipgrep searches for text patterns inside ZIP archives without requiring manual extraction. It works as a shell wrapper around unzip and egrep, piping decompressed file contents through pattern matching to display results in a familiar grep-like format. Pattern matching supports extended regular expressions through egrep. The output shows the matching filename and line for each hit, similar to running grep on extracted contents. Optional member arguments restrict the search to specific files within the archive. All options before the ZIP archive filename are passed to egrep, so standard grep options like -i for case-insensitive matching, -n for line numbers, -c for match counts, and -l for listing matching filenames are all supported. If the literal filename is not found, the suffix .zip is appended. zipgrep is part of the Info-ZIP suite of utilities.
参数
- -i
- Case insensitive.
- -n
- Show line numbers.
- -c
- Count matches.
- -l
- List files only.
- -h
- No filename prefix.
- -v
- Invert match.
- -x _xfile(s)_
- Exclude specified archive members from processing. Wildcards match directory separators.
FAQ
What is the zipgrep command used for?
zipgrep searches for text patterns inside ZIP archives without requiring manual extraction. It works as a shell wrapper around unzip and egrep, piping decompressed file contents through pattern matching to display results in a familiar grep-like format. Pattern matching supports extended regular expressions through egrep. The output shows the matching filename and line for each hit, similar to running grep on extracted contents. Optional member arguments restrict the search to specific files within the archive. All options before the ZIP archive filename are passed to egrep, so standard grep options like -i for case-insensitive matching, -n for line numbers, -c for match counts, and -l for listing matching filenames are all supported. If the literal filename is not found, the suffix .zip is appended. zipgrep is part of the Info-ZIP suite of utilities.
How do I run a basic zipgrep example?
Run `zipgrep [pattern] [archive.zip]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -i do in zipgrep?
Case insensitive.