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

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

问题描述

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

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

推荐答案

&&当第一个命令成功返回或错误级别为0时,在行上运行第二个命令.与&&相反的是||,当第一个命令不成功或错误级别为1时,它将运行第二个命令.

&& runs the second command on the line when the first command comes back successfully, or with an errorlevel of 0. The opposite of && is ||, which runs the second command when the first command is unsuccessful, or with an errorlevel of 1.

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

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