LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

zegrep

Search gzip-compressed files with extended regex

TLDR

Search for pattern in gzipped file
$ zegrep "[pattern]" [file.gz]
copy
Case-insensitive search
$ zegrep -i "[pattern]" [file.gz]
copy
Show line numbers
$ zegrep -n "[pattern]" [file.gz]
copy
Search multiple files
$ zegrep "[pattern]" [file1.gz] [file2.gz]
copy
Extended regex search (alternation, quantifiers)
$ zegrep "(foo|bar)+" [file.gz]
copy

SYNOPSIS

zegrep [grep-options] [-e] pattern [file...]

DESCRIPTION

zegrep searches for patterns in gzip-compressed files without manually decompressing them. It's equivalent to zcat file.gz | egrep pattern but more convenient.The "e" indicates extended regular expression support, same as grep -E. This allows patterns with +, ?, |, and () without escaping.zegrep automatically detects whether input files are compressed. Uncompressed files are searched normally, making it safe to use on mixed file sets.Multiple patterns can be specified with -e or by separating with | in the pattern.

PARAMETERS

-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 (useful for patterns starting with -)

INSTALL

sudo apt install gzip
copy
sudo dnf install gzip
copy
sudo pacman -S gzip
copy
sudo apk add gzip
copy
sudo zypper install gzip
copy
brew install gzip
copy
nix profile install nixpkgs#gzip
copy

CAVEATS

zegrep decompresses files to search them, which uses CPU. For large compressed files, this may be slow.Only gzip compression is supported. For other formats, use bzgrep (bzip2) or xzgrep (xz).Memory usage scales with decompressed file size as the file must be processed through the decompressor.On some systems, zegrep is a script wrapper around zcat and egrep.

SEE ALSO

zgrep(1), zfgrep(1), zcat(1), grep(1), egrep(1), gzip(1), bzgrep(1), xzgrep(1)

Braincup
Open source brain training for math, memory and focus
Braincup mini-games
41 mini-games · Apache-2.0
No ads · No tracking
Play in browser
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid
276 stars
From the maker of Linux Command Library
Copied to clipboard
Braincup
Open source brain training for math, memory and focus. 41 mini-games, from mental arithmetic to Sudoku, N-Back and Solo Chess.
Apache-2.0 licensed · No ads · No tracking · No account
From the maker of Linux Command Library
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid