且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在一行中执行多个命令

更新时间:2023-11-22 13:23:58

Googling给了我: p>




命令B 执行命令A ,然后执行命令B (没有任何评估)






命令B



执行命令A ,并将其所有输出重定向到 >命令B






命令A&命令B 执行命令A ,在运行后评估错误级别,如果退出代码errorlevel)为0,则只能执行命令B






命令A ||命令B



执行命令A ,评估此命令的退出代码,但为0,则只能执行命令B





I know Unix has the following command which can execute multiple commands in a single line, how can I do this in DOS?

command1 ; command2 ; command3 ...

Googling gives me this:


Command A & Command B

Execute Command A, then execute Command B (no evaluation of anything)


Command A | Command B

Execute Command A, and redirect all its output into the input of Command B


Command A && Command B

Execute Command A, evaluate the errorlevel after running and if the exit code (errorlevel) is 0, only then execute Command B


Command A || Command B

Execute Command A, evaluate the exit code of this command and if it's anything but 0, only then execute Command B