Reputation: 1112
Recently I came across this syntax:
${reportName,,}
I could not find anything by googling, so does anyone know what does those ,, mean?
Upvotes: 72
Views: 16779
Reputation: 18391
This is called "Parameter Expansion" available in bash version 4+ . To change the case of the string stored in the variable to lower case.Eg:
var=HeyThere
echo ${var,,}
heythere
You may want to try some additional commands and check the effect:
${var^}
${var^^}
${var,}
${var,,}
Note: "Parameter Expansion" is present in man bash
.Search for it.
https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#Shell-Parameter-Expansion
Upvotes: 80
Reputation: 447
As mentioned by P... this is parameter expansion. Examples below.
myword="Hello"
echo ${myword^} # first letter uppercase
echo ${myword^^} # all uppercase
echo ${myword,} # first letter lowercase
echo ${myword,,} # all lowercase
echo ${myword~} # reverses the case for the first letter
echo ${myword~~} # reverses the case for every letter
Output:
Hello
HELLO
hello
hello
hello
hELLO
Upvotes: 10