#!/usr/bin/env gawk BEGIN { OFS="\t" } NF { count[$1]=++count[$1] rec[$1][count[$1]]=$2 } END { for (head in rec) for (i=1; i