zegrep
Quick Reference
Command Name:
zegrep
Category:
file management
Platform:
Linux/Unix
Basic Usage:
Common Use Cases
Syntax
zegrep [options] pattern [file...]
Options
The zegrep command accepts the same options as the regular egrep command, since it's a wrapper around egrep for compressed files:
Option | Description |
---|---|
-A NUM |
Print NUM lines of trailing context after matching lines |
-B NUM |
Print NUM lines of leading context before matching lines |
-C NUM |
Print NUM lines of output context |
-c |
Print only a count of matching lines per file |
-E |
Use extended regular expressions (implied by zegrep) |
-e PATTERN |
Use PATTERN as the pattern (useful when pattern starts with -) |
-i |
Ignore case distinctions |
-l |
Print only names of files with matches |
-n |
Print line number with output lines |
-o |
Show only the part of a line matching the pattern |
-v |
Select non-matching lines |
-w |
Match only whole words |
--color |
Use markers to highlight the matching strings |
Supported File Formats
The zegrep command can handle compressed file formats:
Extension | Format |
---|---|
.gz |
gzip compressed files |
.Z |
compress (LZW) compressed files (on some systems) |
Examples
How to Use These Examples
The examples below show common ways to use the zegrep
command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.