Text processing - "merging" partial duplicates with count

I have a text file myfile with the following ID name format:

Using only POSIX compliant tools, I'd like to list only duplicate names (column 2) even if they have a different ID (column 1), and append the number of matches so that the output is a null-terminated string that looks like:

The closest I've gotten with a single-liner is with uniq -s to ignore the numbers at the beginning but that makes it output only the first number that it finds, i.e.:

Is there a way to have uniq -s print all duplicate lines without aggregating them, or an entirely different approach?

添加评论
点赞收藏
点踩分享查看原文
评论
?
参与讨论