Forrest logo
tool overview
On this page you find all important commands for the CLI tool zegrep. If the command you are looking for is missing please ask our AI.

zegrep

Zegrep is a command line tool used in Unix and Linux systems for searching and filtering text files based on regular expressions. It is mainly used to perform case-insensitive searches on compressed and uncompressed files.

The command "zegrep" stands for "zcat egrep" which combines the functionalities of the "zcat" and "egrep" commands.

Zegrep is particularly useful for searching within large log files or archives without decompressing them first. It supports various compression formats like Gzip, Bzip2, and Xz.

When used, zegrep reads the compressed file, decompresses it on the fly, and then applies the provided regular expression pattern to match desired lines.

By default, zegrep displays the matching lines along with the file name and line number. It highlights the matched patterns and displays them in color for easier identification.

It also allows users to specify multiple regular expressions, which it treats as a logical OR condition, returning lines that match any of the given patterns.

Zegrep provides several options to modify its behavior, such as the ability to invert the match, display a specific number of lines before and after the match, and suppress filename and line number output.

With zegrep, you can search for complex patterns using regular expressions, enabling powerful text filtering capabilities for various data processing and analysis tasks.

Overall, zegrep is a versatile and efficient tool for searching and filtering text in compressed and uncompressed files using regular expressions.

List of commands for zegrep:

  • zegrep:tldr:1e432 zegrep: Search for extended regular expressions (supporting `?`, `+`, `{}`, `()` and `|`) in a compressed file (case-insensitive).
    $ zegrep --ignore-case "${search_pattern}" ${filename}
    try on your machine
    explain this command
  • zegrep:tldr:3b3a6 zegrep: Search for lines matching a pattern, printing only the matched text.
    $ zegrep --only-matching "${search_pattern}" ${filename}
    try on your machine
    explain this command
  • zegrep:tldr:adb24 zegrep: Print file name and line number for each match.
    $ zegrep --with-filename --line-number "${search_pattern}" ${filename}
    try on your machine
    explain this command
  • zegrep:tldr:b40a1 zegrep: Search for lines that do not match a pattern.
    $ zegrep --invert-match "${search_pattern}" ${filename}
    try on your machine
    explain this command
  • zegrep:tldr:e24b7 zegrep: Search for extended regular expressions (supporting `?`, `+`, `{}`, `()` and `|`) in a compressed file (case-sensitive).
    $ zegrep "${search_pattern}" ${filename}
    try on your machine
    explain this command
  • zegrep:tldr:f16e7 zegrep: Recursively search files in a compressed file for a pattern.
    $ zegrep --recursive "${search_pattern}" ${filename}
    try on your machine
    explain this command
tool overview