Shell参数扩展需要解释

时间:2013-06-10 09:01:36

标签: shell parameters expansion

我正在学习bash manual

在页面27/166,我真的无法理解最后一个参数扩展:

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

有人可以告诉我这些扩展意味着什么吗?

一些例子也值得赞赏。

1 个答案:

答案 0 :(得分:1)

小写

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

大写

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

Converting string to lower case in Bash shell scripting