条件测试
1.test命令:
字符串测试
算术测试
语法: test EXPRESSION
或
[ EXPRESSION ]
在bash中还有一个[[ ]],它是[]的提高版本。
[[ EXPRESSION ]]
[ 10 \> 9] [[ 10 > 9]]
2. if 的语法结构
if test-commands; then consequent-commands; fi
或
if test-commands; then
consequent-commands
fi
或
if test-commands
then
consequent-commands
fi
3.if...else...fi
if []
then
else
fi
4.if...elif...else...fi
if [];then
commands
elif [];then
commands
else
commands
fi
5.case 语句
case EXPRESSION in
PATTERN1)
commands;;
PATTERN2)
commands;;
esac
原文链接:https://www.f2er.com/bash/391471.html