Хотя будут bash -ориентированные и более умные способы, буквальный перевод вашего кода будет:
declare -A a # you need to explicitly declare an associative array
while read -r x rest; do # "x" is assigned to the first field ($1) and "rest" to the rest
((a[$x]++)) # increment the count
done
for x in "${!a[@]}"; do # iterate over the array
echo "${a[$x]},$x" # print the result
done
Приведенный выше код ожидает ввода через stdin, и вам нужно передать ввод с помощью перенаправления или канала.