-a 与
-o 或
! 非
&&:与
||:或
颜色:
yang01@yang01-virtual-machine:~/桌面$ echo -e "\e[031m你好"
你好
yang01@yang01-virtual-machine:~/桌面$ echo -e "\e[032m你好"
你好
组合:
yang01@yang01-virtual-machine:~/桌面$ [ -d /etc/qqq ] && echo -e "\e[032m是目录" || echo -e "\e[031m不是目录"
不是目录
yang01@yang01-virtual-machine:~/桌面$ [ 1=2 ] && echo && echo -e "\e[032myes" || echo -e "\e[031mNO"
yes
yang01@yang01-virtual-machine:~/桌面$ [ 1 = 2 ] && echo && echo -e "\e[032myes" || echo -e "\e[031mNO"
NO
-a
yang01@yang01-virtual-machine:~/桌面$ [ 1 = 1 -a 2 = 3 ] && echo "Y" || echo "N"
N
yang01@yang01-virtual-machine:~/桌面$ [ 1 = 1 -a 2 = 2 ] && echo "Y" || echo "N"
Y
[[]]
yang01@yang01-virtual-machine:~/桌面$ [[ 1 = 1 && 2 = 2 ]] && echo "Y" || echo "N"
Y