I am trying to write a function which will take 2 parameters. 1st a color name, 2nd text to be printed. I have also declared variables for colors as global variables. I want to expand the values by using 1st parameter string.
For now I am using switch case which is the worst way to do it I believe. Thank you in advance
red=$'\e[1;31m'
grn=$'\e[1;32m'
yel=$'\e[1;33m'
blu=$'\e[1;34m'
mag=$'\e[1;35m'
cyn=$'\e[1;36m'
end=$'\e[0m'
Print() {
# I want to use 1st parameter to call the variables above
# i.e. if red is passed, then i want value of red which is '\e[1;31m'
printf $((${1}))
printf "$2"
printf $end
}
function call
Print red "string"