shell5

2021/7/5 7:25:24

本文主要是介绍shell5,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

 -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



这篇关于shell5的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程