Question

What does the code below give as output ?

$declare -A my_array$ my_array=([foo]=bar [baz]=foobar)

$for key in "${!my_array[@]}"; do echo "$key"; done Answer baz foo Question What does the code below give as output ?$ declare -A my_array

$my_array=([foo]=bar [baz]=foobar)$ for key in "${!my_array[@]}"; do echo "$key"; done

?

Question

What does the code below give as output ?

$declare -A my_array$ my_array=([foo]=bar [baz]=foobar)

$for key in "${!my_array[@]}"; do echo "$key"; done Answer baz foo If you want to change selection, open document below and click on "Move attachment" How to use arrays in bash script - LinuxConfig.org x is almost identical, but relies on the use of the ! operator:$ my_array=(foo bar baz) $for index in "${!my_array[@]}"; do echo "$index"; done 0 1 2 The same is valid for associative arrays: <span>$ declare -A my_array $my_array=([foo]=bar [baz]=foobar)$ for key in "${!my_array[@]}"; do echo "$key"; done baz foo As you can see, being the latter an associative array, we can't count on the fact that retrieved values are returned in the same order in which they were declared. Getting the size of a

#### Summary

status measured difficulty not learned 37% [default] 0

No repetitions