Bash Arrays, Strings, and Text Handling/List associative array keys

Expand associative array keys.

Section: Associative Arrays

List associative array keys

bash
bash
printf '%s
' "${!ports[@]}"
Explanation

Useful for loops and reporting.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Associative Arrays
Create associative array
Declare an associative array.
OpenIn sheetbashsame section
Read associative array item
Read a value by key.
OpenIn sheetbashsame section
Loop through key/value pairs
Iterate through an associative array.
OpenIn sheetbashsame section
Create indexed array
Create an indexed array.
OpenIn sheetbash1 tag match
Access array element
Read an array element by index.
OpenIn sheetbash1 tag match
Expand all array items
Expand all array items safely.
OpenIn sheetbash1 tag match