osx - Build Bash variable name -
this question has answer here: dynamic parameter expansion [duplicate] 1 answer i want create function colored output (just learn bash little better) here works esc_seq="\x1b[" # foreground red fg_red="${esc_seq}31;" # background yellow bg_yellow="43;" # style bold fs_bold="1m" # echo echo -e "${fg_red}${bg_yellow}${fs_bold}hello world!" no try build function function ext_echo() { // lets $1 red, $2 yellow, $3 bold // need ... echo -e "${fg_$1}${bg_$2}${fs_$3}hello world!" } how can build echo execution parameters? the following script should enough starting point: #!/bin/bash ext_echo() { declare -a colors colors=( [red]="<red>" [blue]="<blue>" ) c in "$@"; echo ${colors[$c]} done } ext_echo red blue out...