This is an example, would take too longto remove customer details.
2003-09-04 12:20:00 INFO [CUST_REF ] blah blah
2003-09-04 12:20:00 INFO [ John ] blah blah
2003-09-04 12:20:00 INFO [ Doe ] bah blah blah
2003-09-04 12:20:00 INFO [ Gender ]
2003-09-04 12:20:00 INFO [ DOB ]
2003-09-04 12:20:00 INFO [ Postal code ]
2003-09-04 12:20:00 INFO [ Limit 100 ] blah blah
2003-09-04 12:20:00 INFO [ API Value ]
2003-09-04 12:20:00 ERROR [ Error Element ]
2003-09-04 12:20:00 INFO [ Record num ]
2003-09-04 12:20:00 INFO [ status ]
several line of mixed information lines before the next lot of details.
Each lot of details in the square brackets will be different, the x number lines after the CUST_REF will be for that customer. The date/time stirng is not an option because you get more than one customer load in the same second and I don't nesacery want all customers. Just the ones I specify.
I like oombera's sed solution, but I wouldn't have chosen sed because it's a bit mysterious to me. Here's an awk solution.
awk '/CUST_REF/ { i = 11 } i-- > 0' < your_file
When "CUST_REF" is seen on a line, a counter is set for 11 lines. The next pattern selects all lines for which the counter is bigger than 1 and decrements the counter (after the comparison is made --- this is important), but because there is no action associated with it, the default action of "print the current line" is taken.
The perl is similar:
perl -lne '$i = 11 if /CUST_REF/; print if $i-- > 0' < your_file
The perl has the advantage of not having a line length limit (which may not affect your case).