#!/bin/bash awk -F ':' '{list["["$1"]"]=list["["$1"]"]""$2"\n"} END{ for(i in list){printf "%s\n%s",i,list[i]} }' "./nowcoder.txt"