#!/bin/bash read -p "Please enter input separated by commas: " fruits echo "Thanks for the inputs:" IFS="," read -ra fruits_array <<< "$fruits" IFS=" " declare -A fruit_count for fruit in "${fruits_array[@]}"; do fruit=$(echo "$fruit" | xargs | tr '[:upper:]' '[:lower:]') ((fruit_count["$fruit"]++)) done echo "Here are the expected output:" for fruit in "${!fruit_count[@]}" do echo "$fruit - ${fruit_count[$fruit]}" done