column 1 line transitions part two!

I know I have already asked a similar question and the answer was awesome!...But it turns out I need something slightly different. I have a space delimited text file with thousands of lines, COLA.TXT that looks for example like this:
AA 123 456 789
AA 987 987 987
AA 987 988 888
AA 999 999 999
B 123 456 789
B 111 111 111
CCD 123 456 789
CCD 321 654 987
CCD
EE 11 11
EE
EE
EE 00 00 00
EE

Now I need to delete all the last lines of each "section" (sections are determined by the first field of each line)

sample output
AA 123 456 789
AA 987 987 987
AA 987 988 888
B 123 456 789
CCD 123 456 789
CCD 321 654 987
EE 11 11
EE
EE
EE 00 00 00

for sec in $(cut -f 1 -d' ' buf | sort -u); do grep $sec buf | sed '$d'  ; done

thank you for that command....it works BUT....I forgot to mention that in my actual file there are sometimes sections "Y" and "YY" and "Y1" so I had to change grep $sec to grep "$sec "
does that sound about right?

A solution with awk:

awk 'f!=$1{f=$1;s=$0;next}{print s;s=$0}' file

Regards

Another one:

awk '__[$1]++{print _}{_=$0}' file

Nice one Radoulov.:wink:

Thanks :slight_smile:

(added for message too short ...)

Awesome Radoulov...truly a work of awk :wink:

slight modification for this input.

awk '__[substr($1,1,1)]++{print _}{_=$0}' file