Skip to content

Instantly share code, notes, and snippets.

@ogii
Created December 16, 2022 07:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ogii/6991d1f8b71724a20f6469d5cf7f87a6 to your computer and use it in GitHub Desktop.
Save ogii/6991d1f8b71724a20f6469d5cf7f87a6 to your computer and use it in GitHub Desktop.
Iterate through an associative array in bash
declare -A channels=( ["mocha1"]="channel1" ["mocha2"]="channel2" ["mocha3"]="channel3")
for key in "${!channels[@]}"; do
if [ "$key" = "<< parameters.test-name >>" ]; then
echo "${channels[$key]}"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment