bash 中变量名后的 2 个逗号是什么意思?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/41166026/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 15:32:35  来源:igfitidea点击:

What does 2 commas after variable name mean in bash?

linuxbashshell

提问by user1308345

Recently I came across this syntax:

最近我遇到了这个语法:

${reportName,,}

I could not find anything by googling, so does anyone know what does those ,, mean?

我通过谷歌搜索找不到任何东西,所以有人知道那些 ,, 是什么意思吗?

回答by P....

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:

这在 bash 版本 4+ 中称为“参数扩展”。将存储在变量中的字符串的大小写更改为小写。例如:

var=HeyThere
echo ${var,,}
heythere

You may want to try some additional commands and check the effect : source

您可能想尝试一些额外的命令并检查效果:

${var^}
${var^^}
${var,}
${var,,}

Note: "Parameter Expansion" is present in man bash.Search for it.

注意:“参数扩展”存在于man bash.Search 中。