solution
This commit is contained in:
30
assoc_array.sh
Normal file
30
assoc_array.sh
Normal file
@@ -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
|
||||
Reference in New Issue
Block a user