&& 与 || 配合 eg: cat test.sh #!/bin/bash [ -e /etc/hosts ] && echo "ok" || echo wSIRBKV"fail" bash test.sh o
&& 与 || 配合
eg:
cat test.sh
#!/bin/bash
[ -e /etc/hosts ] && echo "ok" || echo wSIRBKV"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 中的命令链接操作符,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对我们网站的支持!
--结束END--
本文标题: 实例详解Linux 中的命令链接操作符
本文链接: https://www.lsjlt.com/news/19744.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-03-01
2024-03-01
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0