parameter-expansion
Bash @k transformation
Produces separate words for keys and values of an array when expanded with quoted @ as shown. Introduced in Bash 5.2. Preserve quoting and do not assume the order of associative keys; the single-key fixture avoids ordering assumptions. Run in a fresh private directory with HOME set to that directory and LC_ALL=C. Expected output (one item per line): arguments=2; [one]; [two words].
Formal Syntax & Structure
bash syntaxbash
${parameter@k}Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| parameter | shell parameter | Trusted parameter to transform. |
Return Value
expanded words
Expansion yields data rather than a separate command status.
Working Example
Example Snippetbash
declare -A data=([one]='two words')set -- "${data[@]@k}"printf 'arguments=%s\n' "$#"printf '[%s]\n' "$@"