Question

I'm learning bash manual.

At page 27/166, I really can't understand the last Parameter Expansion:

${parameter^pattern} 
${parameter^^pattern} 
${parameter,pattern}
${parameter,,pattern}

Can someone please tell me what these expansions mean?

Some examples would also be appreciated.

Was it helpful?

Solution

To lowercase

$ string="A FEW WORDS"
$ echo ${string,}
a FEW WORDS
$ echo ${string,,}
a few words

To uppercase

$ string="a few words"
$ echo ${string^}
A few words
$ echo ${string^^}
A FEW WORDS

Converting string to lower case in Bash shell scripting

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top