while read -n 1 c;do a[c]+=${a[c]}@;done for i in {0..9};do echo -n ${a[c]//@/$i}$i;done