实例详解Linux 中的命令链接 *** 作符

实例详解Linux 中的命令链接 *** 作符,第1张

实例详解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”

总结

以上所述是小编给大家介绍的Linux 中的命令链接 *** 作符,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/903569.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-15
下一篇 2022-05-15

发表评论

登录后才能评论

评论列表(0条)

保存