A command line utility to grep for blocks of text
Project description
cgrep
A command line utility to grep for blocks of text
This tool displays a block of text that matches a regex.
Usage
usage: cgrep [-h] [-k PATTERN] [-i] [-v] [--color] PATTERN [FILE [FILE ...]]
grep blocks of text.
positional arguments:
PATTERN pattern to grep for
FILE file(s) to grep.
optional arguments:
-h, --help show this help message and exit
-k PATTERN, --block-marker PATTERN
regex pattern describing the start of a block
(default=^$)
-i, --ignore-case ignore case distinctions
-v, --invert-match select non-matching blocks
--color use markers to highlight the matching strings
Example
Given the following file,
2018-10-05
Nothing interesting happened.
2018-10-06
cgrep released on github.
2018-10-07
Nobody knows what the future will bring.
Running cgrep on the file produces the following output:
$ cgrep 2018-10-06 diary.txt
2018-10-06
cgrep released on github.
By default, a block begins and ends with an empty line.
This default can be changed with the -k
option.
Footnotes
cgrep was inspired by mgrep. mgrep was (is?) a UNIX command line tool to grep
emails on UNIX accounts, stored as flat files in a format called "mbox".
mgrep-ing a pattern in an mbox displayed the entire email containing the
pattern. cgrep is a generalized version of the mgrep that can grep for any
block of text and not just emails in an mbox. Passing -k '^From '
option to
cgrep is practically equivalent to mgrep.
The "c" in cgrep is largely historical. It originally stood for "context".
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file cgrep-1.0.0.tar.gz
.
File metadata
- Download URL: cgrep-1.0.0.tar.gz
- Upload date:
- Size: 8.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 87930c343adb1c1d6d0a531e528f26cadf9adc075e4a6e5b29add634b7471b47 |
|
MD5 | 9541c37f60669e07d5ccd7364903cf3c |
|
BLAKE2b-256 | 6f7f968d19c91b5baa39bbf701b3764542529bb683047bfadb50a8a1634ad1cf |