[Cialug] Grep Block of Text
Todd Walton
tdwalton at gmail.com
Thu Nov 14 13:42:07 UTC 2019
On Thu, Nov 14, 2019 at 8:19 AM Todd Walton <tdwalton at gmail.com> wrote:
> More often than I'd expect, I find myself wanting to grep for a certain
> pattern in a certain file, and have it return the entire block of text that
> the pattern was in. I wish I had a single command that took three inputs, a
> pattern defining the start of the block, a pattern to find, and a pattern
> defining the end of the block of text.
>
It'd be super cool if I could search for a pattern and tell it to just
gimme the block back, without specifying block starts and ends. Like,
figure it out yourself, little program. Many years back I had a piece of
DOS software called Monarch that would extract patterns from text. You had
to enter information about how the text was structured, but it also had
some ability to do it itself. Like, if you had text in columns it could
reasonably figure out that you wanted those columns to line up. It was the
grooviest thing. I'm sure my memory inflates its groovyness a little, but
it really was awesome. These days I mostly use awk, sed, column, and Miller
(http://johnkerl.org/miller/doc/) for text processing.
--
Todd
More information about the Cialug
mailing list