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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 22:14:58  来源:igfitidea点击:

What does if [[ $# -ge 1 ]] mean in shell scripting

bashshell

提问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。