Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file 使用批处理文件在.txt文件中搜索单词_Batch File - Fatal编程技术网

Batch file 使用批处理文件在.txt文件中搜索单词

Batch file 使用批处理文件在.txt文件中搜索单词,batch-file,Batch File,我正在寻找一个批处理文件来搜索一个txt文件,如果它找到单词“Failed”,那么退出1。有什么帮助吗???这可能会让你开始 type file.txt | find "Failed" 如果返回任何值,则将ERRORLEVEL变量设置为1 希望对你有帮助,伙计 这里有一些类似于Garrett所说的内容,但您可以将其作为后台进程运行,例如在stdout上显示一些其他信息: FindStr "Failed" YourFile.Txt >Nul: If ErrorLevel 1 ...

我正在寻找一个批处理文件来搜索一个txt文件,如果它找到单词“Failed”,那么退出1。有什么帮助吗???

这可能会让你开始

type file.txt | find "Failed"
如果返回任何值,则将ERRORLEVEL变量设置为1


希望对你有帮助,伙计

这里有一些类似于Garrett所说的内容,但您可以将其作为后台进程运行,例如在stdout上显示一些其他信息:

FindStr "Failed" YourFile.Txt >Nul:
If ErrorLevel 1  
  ... then it is NOT found (findstr returns 0 if found
@echo off
@start /wait FIND /C /I "SearchPhrase" path-to-your-file\filename.abc
IF ERRORLEVEL 1 (do-something)