更新时间:2023-11-25 22:18:16
有:
if [ $# -eq 0 ]
then
echo "No arguments supplied"
fi
的 $#
变量会告诉你的输入参数脚本传递的数量。
The $#
variable will tell you the number of input arguments the script was passed.
或者你可以或检查参数为空字符串不喜欢的:
Or you can check if an argument is an empty string or not like:
if [ -z "$1" ]
then
echo "No argument supplied"
fi
的 -z
开关是检验的$ 1的扩张是一个空字符串或没有。如果它是一个空字符串然后执行体
The -z
switch will test if the expansion of "$1" is a null string or not. If it is a null string then the body is executed.