
字符查詢測試的BAT腳本為何出錯
這段代碼的大意是想凡是在2.txt凡是能查找到的關鍵字都寫到reasult.txt文件中了,同時還想把沒有查到的關鍵字寫到reasult1.txt中,但是在if子句中前半句可執性,后半句else子句執行不了。這是為什么啊??有人能解釋一下嗎?謝謝!配套的1.txt和2.txt我上傳到附件里了。如果有知道的兄弟,幫忙給指教一下吧,謝謝啊!nclick="copycode($('code0'));">復制代碼
- @echo off & setlocal EnableDelayedExpansion
- title 字符查詢測試腳本
- color 0a
- for /f delims= %%i in (1.txt) do (
- set string=%%i
- echo !string!
- for /f delims= %%t in ('findstr /m !string! 2.txt') do (
- set str=%%t
- call :abc
- )
- )
- pause
- exit
- :abc
- if not !str!== (
- echo !string!存在于文件:!str! >>reasult.txt
- set str=
- ) else (
- echo !string!不存在 >>reasult1.txt
- )
- :eof

