commit e899afac8534cbc7d255f9e5c35c87e066265d5f Author: Thomas Constans Date: Mon Jun 21 22:45:03 2021 +0200 solution diff --git a/assoc_array.sh b/assoc_array.sh new file mode 100644 index 0000000..7148e88 --- /dev/null +++ b/assoc_array.sh @@ -0,0 +1,30 @@ +#! /bin/bash + +# ref: https://sodocumentation.net/bash/topic/7536/associative-arrays + +set -u +set -e + +declare -A colors=( + [Black]='\e[0;30m' + [Blue]='\e[0;34m' + [Cyan]='\e[0;36m' + [Green]='\e[0;32m' + [Purple]='\e[0;35m' + [Red]='\e[0;31m' + [White]='\e[0;37m' + [Yellow]='\e[0;33m' +# Background + [On_Black]='\e[40m' + [On_Red]='\e[41m' + [On_Green]='\e[42m' + [On_Yellow]='\e[43m' + [On_Blue]='\e[44m' + [On_Purple]='\e[45m' + [On_Cyan]='\e[46m' + [On_White]='\e[47m' + ) + +for k in ${!colors[@]} ; do + echo $k : ${colors[$k]} + done \ No newline at end of file