Linux command
zfgrep 命令
文件
复制后可按需替换文件名、目录或参数。
常用示例
Search for literal string in gzipped file
zfgrep "[string]" [file.gz]
Case-insensitive search
zfgrep -i "[string]" [file.gz]
Show line numbers
zfgrep -n "[string]" [file.gz]
Count matching lines
zfgrep -c "[string]" [file.gz]
List files containing matches
zfgrep -l "[string]" [*.gz]
说明
zfgrep searches for fixed strings in gzip-compressed files without manual decompression. It's equivalent to zcat file.gz | fgrep pattern but more convenient. The "f" indicates fixed string matching (like grep -F). Patterns are interpreted literally, not as regular expressions. This is faster than regex matching and useful when searching for strings containing special characters. zfgrep automatically handles both compressed and uncompressed files, making it safe for mixed file sets. Multiple patterns can be specified, one per line, using -e or by newline-separating them.
参数
- -i
- Case-insensitive matching
- -n
- Show line numbers
- -l
- List filenames with matches only
- -c
- Count matching lines
- -v
- Invert match (show non-matching lines)
- -h
- Suppress filename in output
- -e _pattern_
- Specify pattern
- -x
- Match whole lines only
FAQ
What is the zfgrep command used for?
zfgrep searches for fixed strings in gzip-compressed files without manual decompression. It's equivalent to zcat file.gz | fgrep pattern but more convenient. The "f" indicates fixed string matching (like grep -F). Patterns are interpreted literally, not as regular expressions. This is faster than regex matching and useful when searching for strings containing special characters. zfgrep automatically handles both compressed and uncompressed files, making it safe for mixed file sets. Multiple patterns can be specified, one per line, using -e or by newline-separating them.
How do I run a basic zfgrep example?
Run `zfgrep "[string]" [file.gz]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -i do in zfgrep?
Case-insensitive matching