$? 取上个命令退出码(exit xx, 函数return xx)一般0成功,1失败
#!/bin/sh
echo 'file name:' $0
echo 'param num: ' $#
if [ $# -gt 1 ]; then
echo 'the second param:' $2
fi
./param.shfile name: ./param.sh
param num: 0
./param.sh a
file name: ./param.sh
param num: 1
./param.sh a b
file name: ./param.sh
param num: 2
the second param: b
另:echo 默认输出换行,echo -n 不换行。