小编m.j*_*joe的帖子

如何使用 Windows“findstr”命令搜索字符串的精确匹配?

如何使用Windows命令搜索字符串的精确匹配findstr?例如:我只需要找到与字符串完全匹配的内容store,而不是 stored,storeday等。

以下命令返回所有字符串storestoredstoreday

findstr /l /s /i /m /c:"store" "c:\test\*.txt"
Run Code Online (Sandbox Code Playgroud)

完整脚本:

set "manifest_folder=C:\Calc_scripts*.*"
set "file_list=C:\Search_results\Search_Input.txt"
set "outputfile=C:\Search_results\Search_results.txt"
(for /f "usebackq delims=" %%a in ("%file_list%") do (
    set "found="
    for /f "delims=" %%b in ('findstr /r /s /i /m /c:"%%a" "%manifest_folder%"') do (
        echo %%a is found in %%~nxb
        set "found=1"
    )
    if not defined found (
        echo %%a is not found
    )
))> "%outputFile%" 
Run Code Online (Sandbox Code Playgroud)

windows cmd batch-file findstr

9
推荐指数
1
解决办法
3万
查看次数

标签 统计

batch-file ×1

cmd ×1

findstr ×1

windows ×1