James <wirel...@tampabay.rr.com> writes: > Adam Carter <Adam.Carter <at> optus.com.au> writes: > > >> I need to select all >> the lines between string1 and string2 in a file. String1 exists on > an entire >> line by itself and string2 will be at the start of a line. What's > the syntax? I >> cant use -A as there is a variable number of lines. > > AWK > > is my vote. Old, *SIMPLE* and used by most other packages when > pattern matching is involved. Often AWK and SED go together..... As > do Perl and AWK
Yup and using Steves' example: $ cat a abcd abcd abcd abcd abcd abcd abcd abcd abcd abcd abcd foo <-- /foo/ true here asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf bar <-- /bar/ true here fdsa fdsa fdsa cat a | awk '/^foo/{FLAG=1}\ FLAG{print} \ /^bar/{FLAG=""}' foo asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf bar