【发布时间】:2017-03-07 03:57:37
【问题描述】:
我现在正在处理我在这篇文章中提到的更大的问题...Searching a text file and sending only numbers greater than a certain absolute value to text file?
我想如果我 set num=!num:-=! 的原始值为 -17,那么 !errorlevel! 将评估为 true 或 0 对吗?不过这里有些东西不工作......
为了澄清,我只需要过滤掉第四个标记大于 3 或小于 -3 的行的第一个和第四个标记,以及任何没有第四个标记的行(这部分已解决)。我尝试使用 set 的 /A 选项,但它似乎仍然无法正常工作。
setlocal enabledelayedexpansion
set "min=-"
for /f "tokens=1,4" %%a in ('findstr /b /r /c:"[^ ]*:S:" print.log') do (
if %%b=="" (echo %%a ^*^*^* >>new.txt) else (
set num="%%b"
set num=!num:-=!
if !errorlevel!==0 (
if !num! GTR 3 echo %%a !min!!num! >> new.txt
) else (
if !num! GTR 3 echo %%a !num! >> new.txt
)
)
)
exit /b
print.log 中的文字如下:
ksdf 0 0 -4
as7d:S:asf 0 0 -4
kc:S:cd3 0 0 -2
asdk:S:s 0 0 6
lasd:S:dd 0 0
【问题讨论】:
标签: batch-file cmd errorlevel