网站运营
位置:首页>> 网站运营>> 实例详解Linux 中的命令链接操作符

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

作者:klvchen  发布时间:2023-10-16 03:11:45 

标签: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 中的命令链接操作符,希望对大家有所帮助

来源:https://www.cnblogs.com/klvchen/archive/2018/08/07/9435170.html

0
投稿

猜你喜欢

手机版 网站运营 asp之家 www.aspxhome.com