read -p "Enter yes/no " SOMEVAR
SOMEVAR=`"echo ${SOMEVAR,,}"`
The code above gives me a ${SOMEVAR,,}: bad substitution error.
read -p "Enter yes/no " SOMEVAR
SOMEVAR=`"echo ${SOMEVAR,,}"`
The code above gives me a ${SOMEVAR,,}: bad substitution error.
The parameter expansion ${variable,,} would expand to the value of $variable with all character in lower case in the bash shell. Given that you get a "bad substitution" error when this code runs suggests that you are in fact either
/bin/sh (which is not always bash). But not getting an error for read -p suggests that it's more likely that you arebash which does not support this expansion (introduced in release 4 of bash).The generic form of the expansion is ${variable,,pattern} in which all characters in $variable that matches pattern would be converted to lower case (use ^^ to convert to upper case):
$ str="HELLO"
$ printf '%s\n' "${str,,[HEO]}"
heLLo
See also the bash manual on your system.
For older releases of bash, you could instead do the following to lowercase the value of a variable:
variable=$( tr 'A-Z' 'a-z' <<<"$variable" )
This passes the value of the variable through tr using a "here-string". The tr utility transliterates all characters in the A to Z ASCII range (assuming the C/POSIX locale) to the corresponding character in the a to z range.
Note also that
SOMEVAR=`"echo ${SOMEVAR,,}"`
is better written as
SOMEVAR=${SOMEVAR,,}
In fact, what you wrote would give you a "command not found" error in bash release 4+, unless you have a command called echo string, including the space (where string was what the user inputted). This is due to the command substitution trying to execute the double quoted string.