perl -E"undef$/;map{$a{$_}++}split//,<>;say qq/$_ => $a{$_}/for sort keys%a" test.txt