&&和有什么区别?和 ;在bash或命令? [英] What is the difference between && and ; in bash or command?
本文介绍了&&和有什么区别?和 ;在bash或命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
bash或命令中的&&
和;
有什么区别?
例如:
What is the difference between &&
and ;
in bash or command?
Eg:
~$ echo one && echo two
和
~$ echo one ; echo two
推荐答案
~$ echo one && echo two
仅当第一个命令成功时,此命令才运行2..
This runs the 2. command only if the first command succeeds.
~$ echo one ; echo two
这总是运行2.命令.
~$ echo one || echo two
仅当第一个命令失败时,此命令才运行2..
This runs the 2. command only if the first command fails.
如果命令的退出代码为0,则该命令被视为成功;如果命令的退出代码,则该命令被视为失败. 其退出代码为!= 0.
A command is considered successful if its exit code is 0, and considered failed if its exit code is != 0.
这篇关于&&和有什么区别?和 ;在bash或命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文