Whe*_*tax 3 parameters bash shell if-statement
我遇到过代码
if [ $# -eq 1  ]; then
   echo "usage: Phar ~/flashmem ~/archive"
   exit
fi
我从未见过[$#-eq 1]; 之前和我似乎无法找到意义
"$#"返回作为参数传递的参数数量
#!/bin/bash
echo $#
现在
./testess.sh test1 test2 test3
这回归 $#
./testess.sh test1 test2 test3 test4 test5
这回归 3
因此,在您的代码中,如果"$#"等于第一个(只传递一个参数),请执行echo命令
| 归档时间: | 
 | 
| 查看次数: | 242 次 | 
| 最近记录: |