Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
假设我有一个带有两个参数的脚本,有没有办法检查表单中是否有一个参数或 2 个以上的参数:
if [ check if arguments don't equal 2 ]; then echo Too many arguments exit 1 fi
if [ $# -ne 2 ]; then # Number of arguments was not 2 fi
该变量$#保存传递的参数的数量。
$#