Outline-aware grep program

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Outline-aware grep program

Noel Henson
For those interested...

Here is an outline-aware grep function: otlgrep.py. It works similarly to
grep and allows searching of outlines for information. If a match is found,
the matching line's parents, itself and its children are printed to stdout.

For example



Examples

Using this outline:

Pets
Indoor
        Cats
                Sophia
                Hillary
        Rats
                Finley
                Oliver
        Dogs
                Kirby
Outdoor
        Dogs
                Kirby
                Hoover
        Goats
                Primrose
                Joey

a grep for Sophia returns:

Indoor
        Cats
                Sophia

a grep for Dogs returns:

Indoor
        Dogs
                Kirby
Outdoor
        Dogs
                Kirby
                Hoover

a grep for Kirby returns:

Indoor
        Dogs
                Kirby
Outdoor
        Dogs
                Kirby




Usage:
otlgrep.py [options] pattern [file...]
Options
    -i            Ignore case
    --version     Print version (RCS) information.
    --help        Show help.
output is on STDOUT


file can use wildcards and can have multiple file names like:

otlgrep -i testproject ~/projects/*.otl ~/todo.otl

I haven't added directory recursion yet. I'll probably have to now that I'm
sharing this. :)

Let me know what you think.

Noel

--

------------------------------------------------------------------
  Noel Henson
  www.noels-lab.com Chips, firmware and embedded systems
  www.vimoutliner.org Work fast. Think well.


_______________________________________________
VimOutliner mailing list
[hidden email]
http://www.lists.vimoutliner.org/mailman/listinfo/vimoutliner

otlgrep.py (4K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Outline-aware grep program

Noel Henson
Here is a new version. This one accepts data from stdin if no input files
are specified. There is a bit more help and duplicate printing of parent
headings has been fixed.

Have fun!

Noel

--

------------------------------------------------------------------
  Noel Henson
  www.noels-lab.com Chips, firmware and embedded systems
  www.vimoutliner.org Work fast. Think well.


_______________________________________________
VimOutliner mailing list
[hidden email]
http://www.lists.vimoutliner.org/mailman/listinfo/vimoutliner

otlgrep.py (5K) Download Attachment