declare -A array=( ["first key"]="first value" ["second key"]="second value" ["third key"]="third value") printf '%s\n' 'Using "${!array[@]}":'printf ' - %s\n' "${!array[@]}" printf '\n%s\n' 'Using "${!array[*]}":'printf ' - %s\n' "${!array[*]}" printf '\n%s\n' 'Using ${!array[*]}:'printf ' - %s\n' ${!array[*]} printf '\n%s\n' 'Using ${!array[@]}:'printf ' - %s\n' ${!array[@]}
Standard input is empty
Using "${!array[@]}": - second key - third key - first key Using "${!array[*]}": - second key third key first key Using ${!array[*]}: - second - key - third - key - first - key Using ${!array[@]}: - second - key - third - key - first - key
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!