This was new to me:
Code: Select all
# In Bash 4.0
a=DHCP
echo "${a,,}"
# Output:
dhcp
https://www.codegrepper.com/search.php? ... per%20case
Code: Select all
var=hello #For Bash Version higher than 4.3.33 try these
echo ${var''} #Uppercase whole string
HELLO
echo ${var'} #Uppercase only first char of string
Hello
var2=BYE
echo ${var2,} #Lowercase whole string
bye
echo ${var2,,} #Lowercase only first char of string
bYE
but...
Code: Select all
echo ${var'}
echo ${var''}
didn't work for me. Maybe copied and pasted it wrong or wrong character(s) after var?
Ah, seems to be wrong on website, should be:
Code: Select all
echo ${var^}
echo ${var^^}
or
Code: Select all
echo ${var~}
echo ${var~~}
GNU bash, version 5.0.17(1)-release