Linux 命令 - shell 运算符
简介
- && :符合条件作动作。
- || :不符合条件作动作。
- 官方文档:https://www.gnu.org/software/bash/manual/bash.html#Shell-Arithmetic
实例
[root@ test_test]# a=1
[root@ test_test]# b=2
[root@ test_test]# [ "$a" -lt "$b" ] && echo "符合条件作动作" || echo "不符合条件作动作"
符合条件作动作
[root@ test_test]# [ "$a" -gt "$b" ] && echo "符合条件作动作" || echo "不符合条件作动作"
不符合条件作动作
[root@ test_test]#