1

Similar to this Print array elements on separate lines in Bash? but printing only the keys.

The answer on that other one %s\n' "${myarray[@]}" when used on an associative array prints the values only while I'm looking for the keys.

declare -r -A myarray=(
   [a]=1
   [b]=2
   [c]=3
   [d]=4
)

Would like to have:

a
b
c
d
0

1 Answer 1

4

So just:

printf "%s\n" "${!myarray[@]}"
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.