#!/bin/bash
if test $# -eq 0
then
echo "No arguments"
elif test $# -eq 1
echo "$1"
elif test $# -eq 2
echo "$1 $2"
else
echo "More than 2 arguments"
fi
#!/bin/bash
if test "$#" -eq 0
then
printf 'No arguments\n'
elif test "$#" -eq 1
then
printf '%s\n' "$1"
elif test "$#" -eq 2
then
printf '%s %s\n' "$1" "$2"
else
printf 'More than 2 arguments\n'
fi
#!/bin/bash
if test $# -eq 0
then
echo "No arguments"
elif test $# -eq 1
then
echo "$1"
elif test $# -eq 2
then
echo "$1 $2"
else
echo "More than 2 arguments"
fi
if/elif/else/fi 的语法
then
在每个“elif”之后都需要一个:我还用 s替换了你
echo
的printf
s并引用了 $# 的实例。你需要一个
then
afterelif
。