0

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
user5507535
  • 1,081
  • 10
  • 22

1 Answers1

1

So just:

printf "%s\n" "${!myarray[@]}"
KamilCuk
  • 96,430
  • 6
  • 33
  • 74