Artificial intelligent assistant

Insert new line after non matching pattern I have following output from script host1:101 host1:102 host2:101 host2:102 host2:103 host4:101 host5:101 host5:102 host5:103 host5:104 etc.. I wanted to insert a new line after each host group. host1:101 host1:102 host2:101 host2:102 host3:101 host3:102 Any AWK onliners to compare each consecute line with 1st field and insert new line before non-matching 1st field?

awk -F: '{if (NR>1 && save!=$1) print "";} {save=$1; print;}'


You never want to insert a blank line before line 1, so don't even think about it unless `NR>1`. Thereafter, print the blank line if the first field is not the saved value from the previous line.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy ca16d9c291b28c6cd9baa09d31ae3929