“&"是什么意思?在这个批处理文件中做什么? [英] What does "&&" do in this batch file?

查看:38
本文介绍了“&"是什么意思?在这个批处理文件中做什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从回答我一个问题的人那里收到了一行代码,但我很困惑:&&"是什么意思在这个批处理文件中做.

I received a line of code from someone who answered one of my questions, but I am confused: what do the "&&" do in this batch file.

@echo off
set /p Quest="How are you today? "
echo %Quest% > Results.txt
findstr /r /i "not.*good not.*well" Results.txt >nul && echo Sorry && goto pause
findstr /i "good well" Results.txt >nul && echo My day is doing good as well
:pause
pause

推荐答案

&& 当第一个命令成功返回时(即 errorlevel ==0).&& 的反义词是 ||,它在第一个命令不成功时运行第二个命令(即 errorlevel != 0).

&& runs the second command on the line when the first command comes back successfully (i.e. errorlevel == 0). The opposite of && is ||, which runs the second command when the first command is unsuccessful (i.e. errorlevel != 0).

这篇关于“&"是什么意思?在这个批处理文件中做什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆