if expression1; then
statement...;
elif expression2; then
statement...;
...
elif expressionN; then
statement...;
else
statement...;
fi
解释:
当expression
的运行结果为0
,表示真
;
当expression
的运行结果为非0
,表示假
。
if [ -f "/etc/alpine-release" ] ; then
echo "your os is AlpineLinux"
elif [ -f "/etc/debian_version" ] ; then
echo "your os is Debian"
elif [ -f "/etc/lsb-release" ] ; then
echo "your os is Ubuntu"
elif [ -f "/etc/fedora-release" ] ; then
echo "your os is Fedora"
elif [ -f "/etc/centos-release" ] ; then
echo "your os is CentOS"
elif [ -f "/etc/redhat-release" ] ; then
echo "your os is RHEL"
else
echo "your os is not recognized!"
fi