demo 接收一个参数
sh testif.sh 1
#! /bin/bash
set -e
base=.
type=$1
if [ ! $type ]
then
echo "type is null"
elif [ $type -eq 0 ]
then
echo "type is 0"
elif [ $type -eq 1 ]
then
echo "type is 1"
else
echo "type is other"
fi
注意点:
1、每一个if 或者elif后面需要一个then
2、if 的条件判断[]中的表达式必须和[或者]留有一个字符的宽度