Scripting Question - getting lines above ane below certain enteries

Hello -
I have a file in the followig format

LINE TEXT 1
Line TEXT 2
TIMESTARTED=Fri Aug 16 15:20:23 EDT 2013
START-OF-DATA
123
123444
23232323
END-OF-DATA
Line TEXT 9

I need to get all the lines between the Start of Data and End of Data and pipe it to a file so output should be

123
12344
2332323

Can you please recommed a command line option that could work
maybe using Awk Sed Grep ?

Thanks

sed -n '/^START-OF-DATA/,/^END-OF-DATA/{//!p};' file | tee outfile
123
123444
23232323

cat outfile
123
123444
23232323
sed -n '
    /^START-OF-DATA/,/^END-OF-DATA/{
        /-OF-DATA/d
        w outfile
    }
 ' file

awk

awk '/START-OF-DATA/{f=1;next} /END-OF-DATA/{f=0} f' file

thank you both -- I will try both and let you know how it goes
Really appreciate it!!

Placing the conditional print ( p or p!=0 {print} ) after the conditional {p=0} and before the conditional {p=1} saves a next

awk '/END-OF-DATA/{p=0} p; /START-OF-DATA/{p=1}' file

In general it's more robust to process the end condition only after the start condition was met

awk 'p&&/END-OF-DATA/{p=0} p; /START-OF-DATA/{p=1}' file
1 Like