实例详解Linux 中的命令链接操作符
这篇文章通过实例代码给大家详细介绍了Linux 中的命令链接操作符,非常不错,具有一定的参考借鉴价值,需要的朋友参考下吧
&& 与 || 配合
1 2 3 4 5 6 7 8 9 10 11 12 13 | 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 注意这里 && 必须在 || 之前 |
命令合并操作符 {}
1 2 | [ -f /home/tecmint/Downloads/xyz1 .txt ] || { touch /home/tecmint/Downloads/xyz .txt; echo "The file does not exist" } “The file does not exist” |
总结
以上所述是小编给大家介绍的Linux 中的命令链接操作符,希望对大家有所帮助