extract all text lines between 2 lines in a file?
Bob Bell
bbell at hp.com
Wed Apr 7 16:18:01 EDT 2004
On Wed, Apr 07, 2004 at 03:05:52PM -0400, Tom Buskey <tom at buskey.name> wrote:
> > #!/bin/sh
> >
> > command1
> > command2
> > uniqdelimiter
> > command3
> > command4
> > uniqdelimiter
> > command5
> >
> > I want to filter it and get:
> > command3
> > command4
> >
> > In other words, everything between the lines that say "uniqdelimter".
> >
> > This will do it:
> > sed '0,/^uniqdelimiter/d' file | sed '/^uniqdelimter/d'
> >
> > but I'd like a one liner in sed, grep or awk. I'll settle for perl too
> > :-)
> >
>
> I answered my own question:
>
> sed '0,/^uniqdelimiter/d' -e '/^uniqdelimter/d' file
Odd, doesn't seem to be working for me.
FWIW, a Perl solution:
perl -ne 'print if $m==1 and not /^uniqdelimiter/;$m+=/^uniqdelimiter/;' file
--
Bob Bell
More information about the gnhlug-discuss
mailing list