实例详解Linux 中的命令链接操作符
&& 与 || 配合
eg: cat test.sh #!/bin/bash [ -e /etc/hosts ] && echo "ok" || echo "fail" bash test.sh ok eg: cat test.sh #!/bin/bash [ -e /etc/hostssssss ] && echo "ok" || echo "fail" bash test.sh fail 注意这里 && 必须在 || 之前
命令合并操作符 {}
[ -f /home/tecmint/Downloads/xyz1.txt ] || {touch /home/tecmint/Downloads/xyz.txt; echo "The file does not exist"} “The file does not exist”
总结
相关推荐
farwang 2020-11-25
星愿心愿 2020-11-24
tianhuak 2020-11-24
zhjn0 2020-11-24
昭君出塞 2020-11-23
bluecarrot 2020-11-23
linuxwcj 2020-10-21
以梦为马不负韶华 2020-10-20
彼岸随笔 2020-10-20
yutou0 2020-10-17
applecarelte 2020-10-16
ourtimes 2020-10-16
waterhorse 2020-09-19
MRFENGG 2020-11-11
rainandtear 2020-10-30
kyssfanhui 2020-10-20
liuhangtiant 2020-10-20