سؤال

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.

هل كانت مفيدة؟

المحلول

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

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top