Delete all CONSECUTIVE text lines from file shell scripting

Hi

I have a text file like below. THe content of the text will vary.

Entire text file have four consecutive lines followed with blank line.

I want to delete the occurrence of the two consicutive lines in the text file. I don't have pattern to match and delete. Just i need to delete all two lines in the text file.

a
a
a
a
 
a
a

a
a
a
a

a
a
a
a

Any attempts/ideas/thoughts from your side?

No ... After searching i didnt get any idea anywhere.

I was more talking of your own efforts... anyhow, try

awk '/^ *$/ {CNT = 0; print; next} ++CNT < 3 {T[CNT] = $0; next} CNT == 3 {print T[1]; print T[2]} 1' file
1 Like

Thanks Much it is working fine and suits my requirement

awk 'NF>2' RS="\n\n" ORS="\n\n" infile