findstr 退出 codes/errorlevel
findstr exit codes/errorlevel
我有一个使用 findstr
的程序,当找到字符串时 errorlevel
returns 0
当找不到字符串时 errorlevel
returns 1
。好的,没关系,我可以处理。
问题在于我找不到任何关于每个 errorlevel
对 findstr
意味着什么的官方文档。我需要知道 findstr
的其他任何东西是否可以 return 一个 1
的 errorlevel
,或者是否只有 returns 1
当找不到字符串。
首选 'official' 文档链接(如果有的话),但我们将不胜感激。
提前致谢!
在 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.
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.
我有一个使用 findstr
的程序,当找到字符串时 errorlevel
returns 0
当找不到字符串时 errorlevel
returns 1
。好的,没关系,我可以处理。
问题在于我找不到任何关于每个 errorlevel
对 findstr
意味着什么的官方文档。我需要知道 findstr
的其他任何东西是否可以 return 一个 1
的 errorlevel
,或者是否只有 returns 1
当找不到字符串。
首选 'official' 文档链接(如果有的话),但我们将不胜感激。
提前致谢!
在 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.
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.