bash if [[ $# -ge 1 ]] 在 shell 脚本中意味着什么
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/36753717/
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
What does if [[ $# -ge 1 ]] mean in shell scripting
提问by mb47
I was going over some files and found this:
我正在查看一些文件,发现了这个:
if [[ $# -ge 1 ]]
What does that mean?
这意味着什么?
回答by Jeff Puckett
if the number of passed parameters is greater than or equal to 1
如果传递的参数数量大于或等于 1
回答by Krishna
In shell script $# stores the number of arguments passed from the command line, like *argc in c programming.
在 shell 脚本中 $# 存储从命令行传递的参数数量,就像 c 编程中的 *argc。
So, By using the "if" statement we are verify the number of arguments are greater than or equal to one.
因此,通过使用“if”语句,我们可以验证参数的数量是否大于或等于 1。