shell脚本if判断多个条件(shell中if怎么判断多个条件)

本文目录
shell中if怎么判断多个条件
if [ expression 1 ]
then
Statement(s) to be executed if expression 1 is true
elif [ expression 2 ]
then
Statement(s) to be executed if expression 2 is true
elif [ expression 3 ]
then
Statement(s) to be executed if expression 3 is true
else
Statement(s) to be executed if no expression is true
fi
shell多个条件判断
可以用case
#!/bin/sh
case a1 in
111)
ttt
;;
222)
ttt
;;
*)
bbb
;;
esac
shell if 多条件判断
#其中mkdir外面的符号是esc下来那个按键上的符号,表示执行命令
#!/bin/bash
if [ `mkdir -p ~/1/1` -a `mkdir ~/2` ];then
echo “成立{$?}“
else
echo “不成立{$?}“
fi
shell if 多个条件的编写
if [ “$file“ = “$i“ -a -d $file -a -d $i ]
其实
if [ “$file“ = “$i“ -a -d $file ]
因为既然 file 等于 i, 那么 file 是目录,则 i 也一定是目录,所以判断了 file 就不用再判断 i 了

更多文章:
shell脚本if判断多个条件(shell中if怎么判断多个条件)
2026年10月14日 22:40
progressive trance(trance 与 techno 详细解释)
2026年10月14日 21:50
php培训机构有哪些(天津有口碑不错的的学习PHP的培训机构推荐吗)
2026年10月14日 21:20
tcp三次握手详细过程(TCP/IP三次握手具体过程是什么)
2026年10月14日 21:00





