美文网首页
Bash命令连接符 | &&等

Bash命令连接符 | &&等

作者: wyonxue | 来源:发表于2018-01-10 11:52 被阅读0次

Bash命令连接符 | &&等

来自Stack上一篇回答Running multiple commands in one line in shell

To summarize (non-exhaustively) bash's command operators/separators:

  • | pipes (pipelines) the standard output (stdout) of one command into the standard input of another one. Note that stderr still goes into its default destination, whatever that happen to be.

  • |& pipes both stdout and stderr of one command into the standard input of another one. Very useful, available in bash version 4 and above.

  • && executes the right-hand command of && only if the previous one succeeded.

  • || executes the right-hand command of || only it the previous one failed.

  • ; executes the right-hand command of ; always regardless whether the previous command succeeded or failed. Unless set -e was previously invoked, which causes bash to fail on an error.

相关文章

网友评论

      本文标题:Bash命令连接符 | &&等

      本文链接:https://www.haomeiwen.com/subject/usfonxtx.html