Tldr: page request: zgrep

Created on 5 Apr 2020  路  3Comments  路  Source: tldr-pages/tldr

Zgrep can search on compressed files. description is below link.

https://linux.die.net/man/1/zgrep

help wanted new command

Most helpful comment

I am no expert on peoples different implementations of zgrep that they are running.
But as my machine using using GNU grep I can easily read that:

Zgrep invokes grep on compressed or gzipped files. _All options specified are passed directly to grep_

Together with:

The following grep options are not supported: --dereference-recursive (-R), --directories (-d), --exclude, --exclude-from, --exclude-dir, --include, --null (-Z), --null-data (-z), and --recursive (-r).

Thus checking the tldr grep

  Matches patterns in input text.
  Supports simple patterns and regular expressions.

  Search for an exact string:

      grep search_string path/to/file

  Search in case-insensitive mode:

      grep -i search_string path/to/file

  Search recursively (ignoring non-text files) in current directory for an exact string:

      grep -RI search_string .

  Use extended regular expressions (supporting `?`, `+`, `{}`, `()` and `|`):

      grep -E ^regex$ path/to/file

  Print 3 lines of [C]ontext around, [B]efore, or [A]fter each match:

      grep -C|B|A 3 search_string path/to/file

  Print file name with the corresponding line number for each match:

      grep -Hn search_string path/to/file

  Use the standard input instead of a file:

      cat path/to/file | grep search_string

  Invert match for excluding specific strings:

      grep -v search_string

It looks like one could probably use the grep page for heavy inspiration of how to write the zgrep one. :)

All 3 comments

Thanks for requesting this page! Do you want to have a go yourself?

Pages are best created by people who understand the command they are about.

If you do, take a quick read of CONTRIBUTING.md, which guides you through the process of creating a new page here. Then, just simply send a pull request to this repository - and if you need any assistance, just ask :-)

I am no expert on peoples different implementations of zgrep that they are running.
But as my machine using using GNU grep I can easily read that:

Zgrep invokes grep on compressed or gzipped files. _All options specified are passed directly to grep_

Together with:

The following grep options are not supported: --dereference-recursive (-R), --directories (-d), --exclude, --exclude-from, --exclude-dir, --include, --null (-Z), --null-data (-z), and --recursive (-r).

Thus checking the tldr grep

  Matches patterns in input text.
  Supports simple patterns and regular expressions.

  Search for an exact string:

      grep search_string path/to/file

  Search in case-insensitive mode:

      grep -i search_string path/to/file

  Search recursively (ignoring non-text files) in current directory for an exact string:

      grep -RI search_string .

  Use extended regular expressions (supporting `?`, `+`, `{}`, `()` and `|`):

      grep -E ^regex$ path/to/file

  Print 3 lines of [C]ontext around, [B]efore, or [A]fter each match:

      grep -C|B|A 3 search_string path/to/file

  Print file name with the corresponding line number for each match:

      grep -Hn search_string path/to/file

  Use the standard input instead of a file:

      cat path/to/file | grep search_string

  Invert match for excluding specific strings:

      grep -v search_string

It looks like one could probably use the grep page for heavy inspiration of how to write the zgrep one. :)

Reference in the associated PR didn't auto-close this issue (no closes prefix), so since it has been merged I'm closing this issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dikarel picture dikarel  路  4Comments

Wesalius picture Wesalius  路  3Comments

FukurouMakoto picture FukurouMakoto  路  3Comments

hrai picture hrai  路  3Comments

waldyrious picture waldyrious  路  4Comments