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

zgrep

Zgrep is a command line tool used for searching and manipulating text files compressed with gzip compression. It allows you to search for specific patterns or strings within compressed files without having to decompress them first. Here are some key points about zgrep:

  1. Zgrep works with gzip compressed files and can search for patterns in these files directly.
  2. It is similar to regular grep, but with the ability to work on compressed files.
  3. By default, zgrep prints matching lines to the standard output.
  4. It supports various search options like case-insensitive searches, multiple patterns, and regular expressions.
  5. You can use zgrep to search for patterns across multiple compressed files at once.
  6. Zgrep automatically decompresses the compressed input files on-the-fly while searching for the patterns.
  7. The tool can handle files compressed with other compression formats like .Z and .bz2 using appropriate options.
  8. Zgrep offers additional options for controlling the output format, such as printing the matching filenames alongside the matched lines.
  9. It provides options to limit or expand the search to specific line numbers or byte offsets within the compressed files.
  10. Zgrep is a powerful tool for efficiently searching and analyzing text within compressed files, saving time and storage space.

List of commands for zgrep:

  • zgrep:tldr:3d6eb zgrep: Grep a pattern in a compressed file (case-insensitive).
    $ zgrep -i ${pattern} ${path-to-compressed-file}
    try on your machine
    explain this command
  • zgrep:tldr:6b70e zgrep: Grep a pattern in a compressed file (case-sensitive).
    $ zgrep ${pattern} ${path-to-compressed-file}
    try on your machine
    explain this command
  • zgrep:tldr:8a78d zgrep: Output count of lines containing matched pattern in a compressed file.
    $ zgrep -c ${pattern} ${path-to-compressed-file}
    try on your machine
    explain this command
  • zgrep:tldr:bef93 zgrep: Display the lines which don’t have the pattern present (Invert the search function).
    $ zgrep -v ${pattern} ${path-to-compressed-file}
    try on your machine
    explain this command
  • zgrep:tldr:d6dc1 zgrep: Use extended regular expressions (supporting `?`, `+`, `{}`, `()` and `|`).
    $ zgrep -E ${regular_expression} ${filename}
    try on your machine
    explain this command
  • zgrep:tldr:ef04d zgrep: Print 3 lines of [C]ontext around, [B]efore, or [A]fter each match.
    $ zgrep -${select} ${3} ${pattern} ${path-to-compressed-file}
    try on your machine
    explain this command
  • zgrep:tldr:f47ac zgrep: Grep a compressed file for multiple patterns.
    $ zgrep -e "${pattern_1}" -e "${pattern_2}" ${path-to-compressed-file}
    try on your machine
    explain this command
tool overview