我有一个使用findstr的程序,当找到字符串时,errorlevel返回0,当没有找到字符串时,errorlevel返回1。好的,没问题,我能处理好。
问题的症结在于,我找不到任何关于每个errorlevel对findstr意味着什么的官方文档。我需要知道findstr是否还有其他东西可以返回1的errorlevel,或者当没有找到字符串时,它是否只返回1。
如果有的话,最好是“官方”文档的链接,但如果有任何意见,我们将不胜感激。
提前感谢!
发布于 2015-08-04 23:31:55
http://ss64.com/nt/findstr.html说:
FINDSTR will set %ERRORLEVEL% as follows:
0 (False) a match is found in at least one line of at least one file.
1 (True) if a match is not found in any line of any file, (or if the file is not found at all).
2 Wrong syntax
An invalid switch will only print an error message in error stream.发布于 2015-08-04 22:46:44
它记录在Dos 6.22的FIND命令的帮助中。
│FIND exit codes
│
│The following list shows each exit code and a brief description of its
│meaning:
│
│0
│ The search was completed successfully and at least one match was found.
│
│1
│ The search was completed successfully, but no matches were found.
│
│2
│ The search was not completed successfully. In this case, an error
│ occurred during the search, and FIND cannot report whether any matches
│ were found.
│
│You can use the ERRORLEVEL parameter on the <If> command line in a batch
│program to process exit codes returned by FIND.https://stackoverflow.com/questions/31810950
复制相似问题