Bash arrays

From Skytech
Revision as of 07:17, 23 March 2020 by Martin (talk | contribs) (Created page with "category: Linux = Arrays - bash = <pre> ## Declare associate array: declare -A OFFICES ## Assign data OFFICES[Southampton]=0 ## Loop array for key in "${!OFFICES[@]}"...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search


Arrays - bash

## Declare associate array:
declare -A OFFICES

## Assign data
OFFICES[Southampton]=0

## Loop array
for key in "${!OFFICES[@]}";
do
    echo "openvpn{office=\"${key}\"} ${OFFICES[$key]}" >> ${PROM_METRICS_HTML_FILE}
done