在我组织的许多脚本中,甚至在在线教程中,这都是if
我遇到的一个常见条款:
if [ $# -eq "somethng" -o $# -eq "somethng" ]
此$#
条件与什么匹配-默认情况下某些用户输入?
可以直接在命令行上使用吗?
$#
是您传递给bash脚本的参数数量,不计算$0
,这是程序名称。
例子:
#!/bin/bash
echo "Number of arguments is: $#"
然后运行:
% cuonglm at ~
% ./test.sh a b c d
Number of arguments is: 4
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句