2016-08-09 2 views
0

Windows findstrコマンドを使用して文字列の完全一致を検索するにはどうすればよいですか? 例えば:私は完全一致に文字列を検索する必要はstoreではなく storedstoredayなどウィンドウ `findstr`コマンドを使用して文字列の完全一致を検索するには?

以下のコマンドを返しますすべての文字列、storestoredstoreday

findstr /l /s /i /m /c:"store" "c:\test\*.txt" 

完全なスクリプト:

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%" 
+0

文字列?例えば。 findstr/l/s/i/m/c: "store" "c:\ test * .txt" –

+1

findstr/R/S/I/M/C: "\ " "C:\ test * .txt "' – aschipfl

+0

@DavyC:スペースを追加すると、calcスクリプトのリストで文字列を検索しているため、機能しません。 "ストア"、 "ストア"、 "ストア"、@関数(ストア)など。 –

答えて

0

findstr /?ヘルプによると、0

Regular expression quick reference: 
    .  Wildcard: any character 
    *  Repeat: zero or more occurrences of previous character or class 
^  Line position: beginning of line 
    $  Line position: end of line 
    [class] Character class: any one character in set 
    [^class] Inverse class: any one character not in set 
    [x-y] Range: any characters within the specified range 
    \x  Escape: literal use of metacharacter x 
    \<xyz Word position: beginning of word 
    xyz\> Word position: end of word 

は、したがって、あなたは、このようなあなたのfindstrコマンドラインを変更する必要があります:それが必要あなたの完全なスクリプトでそう

findstr /l /s /i /m /c:"\<store\>" "c:\test\*.txt" 

からと\>表す単語の境界次の抜粋を参照してください次のようになります。

findstr /r /s /i /m /c:"\<%%a\>" "%manifest_folder%" 
関連する問題