Pregunta

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.

¿Fue útil?

Solución

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

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top