gawk -v"RS=\r?\n| " "{++a[$0][FILENAME];f[FILENAME]}END{PROCINFO[\"sorted_in\"]=\"@ind_str_desc\";for(i in a)for(j in f)if(!a[i][j]){};for(i in a){printf i;s=1;for(j in a[i]){sId=s?\":\":\",\";printf sId\" %s 记录 %d 次\",j,a[i][j];s=0}print\"\"}}" 1.txt 2.txt>3.txt