[Solved] summarize consecutive lines containing identical values in a specific field using sed (or awk)?

antiplex Asks: summarize consecutive lines containing identical values in a specific field using sed (or awk)?
So far I’ve been able to get around sed’s more advanced features like look-ahead/look-behind across multiple lines but I’d like to understand how tasks like the following can be achieved with sed as I have the feeling that my approach of doing this e.g. within python is not necessary and can also be done within a filter pipeline on cmd.

a stripped example of the data coming in is like this:

Code:
1b41cf70 0
1cb8dd19 1
620f0b67 2
620f0b67 3
f35d35fe 4
3a6fb62a 5
620f0b67 6
620f0b67 7
620f0b67 8
b958a7ea 9
f35d35fe 10
f35d35fe 11
620f0b67 12

the first columns width is always identical (contains a shortened hash-value) and the second columns content is completely odered, numerical and without gaps (and therefore potentionally unnecessary besides providing orientation on lenghtier lists).

the desired output would be either like this (putting the index of the last consecutive occurance into an additional column):

Code:
1b41cf70 0
1cb8dd19 1
620f0b67 2 3
f35d35fe 4
3a6fb62a 5
620f0b67 6 8
b958a7ea 9
f35d35fe 10 11
620f0b67 12

or even better with aggregated numbers of repeating values (math expressions (adding) seem to be more easily done with awk but my skills with that are even worse, so this is just to illustrate what other outcomes would be desireable):

Code:
1b41cf70 0
1cb8dd19 1
620f0b67 2 +1
f35d35fe 4
3a6fb62a 5
620f0b67 6 +2
b958a7ea 9
f35d35fe 10 +1
620f0b67 12

I tried to follow several similar but yet different questions found across the SO-space but could not wrap my head around possibly simpler parts possibly leading to a solution like why sed '$!N;/^([^ ]+) [0-9]+n1 /{P;d}' sampledata will cut lines with indexes 3,7,11 but not 8.

My system has GNU sed version 4.8 and awk version 5.1.0 installed and I’d love to learn how I could use one of them to get this done. And no, this is not homework but lengthy lists of hashes with plenty of redundancy that need to be compacted and compared. ;)

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.