Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Bash 检查脚本中的参数数_Bash_Shell_Sh - Fatal编程技术网

Bash 检查脚本中的参数数

Bash 检查脚本中的参数数,bash,shell,sh,Bash,Shell,Sh,如果我至少有3个参数,我如何签入脚本,它必须类似于: if #number_of_arguments < 3 then echo "Not enough arguments" 在bash中,另一种方法是使用算术表达式 if (( $# < 3 )); then ... fi if (( $# < 3 )); then ... fi

如果我至少有3个参数,我如何签入脚本,它必须类似于:

if #number_of_arguments < 3
then
   echo "Not enough arguments"
在bash中,另一种方法是使用算术表达式

if (( $# < 3 )); then
  ...
fi
if (( $# < 3 )); then
  ...
fi