Change variable named in argument to bash function [duplicate]
问题 This question already has answers here : Dynamic variable names in Bash (16 answers) How to use a variable's value as another variable's name in bash [duplicate] (6 answers) Closed 3 years ago . In my bash scripts, I often prompt users for y/n answers. Since I often use this several times in a single script, I'd like to have a function that checks if the user input is some variant of Yes / No, and then cleans this answer to "y" or "n". Something like this: yesno(){ temp="" if [[ "$1" =~ ^([Yy