質問: windowsのfindコマンドとfindstrコマンドの違いは何ですか? windowsでは、findコマンドとfindstrコマンドの違いは何ですか?どちらもファイル内のテキストを検索するようです:見つけるc:\> find /? searches for a text string in a file or files. find [/v] [/c] [/n] [/i] [/off[line]] "string" [[drive:][path]filename[ ...]] /v displays all lines not containing the specified string. /c displays only the count of lines containing the string. /n displays line numbers with the displayed lines. /i ignores the case of characters when searching for the string. /off[line] do not skip files with offline attribute set. "string" specifies the text string to find. [drive:][path]filename specifies a file or files to search. if a path is not specified, find searches the text typed at the prompt or piped from another command. findstrc:\> findstr /? searches for strings in files. findstr [/b] [/e] [/l] [/r] [/s] [/i] [/x] [/v] [/n] [/m] [/o] [/p] [/f:file] [/c:string] [/g:file] [/d:dir list] [/a:color attributes] [/off[line]] strings [[drive:][path]filename[ ...]] /b matches pattern if at the beginning of a line. /e matches pattern if at the end of a line. /l uses search strings literally. /r uses search strings as regular expressions. /s searches for matching files in the current directory and all subdirectories. /i specifies that the search is not to be case-sensitive. /x prints lines that match exactly. /v prints only lines that do not contain a match. /n prints the line number before each line that matches. /m prints only the filename if a file contains a match. /o prints character offset before each matching line. /p skip files with non-printable characters. /off[line] do not skip files with offline attribute set. /a:attr specifies color attribute with two hex digits. see "color /?" /f:file reads file list from the specified file(/ stands for console). /c:string uses specified string as a literal search string. /g:file gets search strings from the specified file(/ stands for console). /d:dir search a semicolon delimited list of directories strings text to be searched for. [drive:][path]filename specifies a file or files to search. use spaces to separate multiple search strings unless the argument is prefixed with /c. for example, 'findstr "hello there" x.y' searches for "hello" or "there" in file x.y. 'findstr /c:"hello there" x.y' searches for "hello there" in file x.y. regular expression quick reference: . wildcard: any character * repeat: zero or more occurences 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 for full information on findstr regular expressions refer to the online command reference.
回答: findstrには、より多くの検索オプションがあり、正規表現をサポートしています。 findstrがファイル名にワイルドカードを使用すると機能しないことがわかりました。以下のコマンドは、パターンquant_2013-10-25 _ *。logを持つ複数のファイル内のすべての検索文字列を返しますfind /i "nfct255c9a" d:\comp1\logs\quant_2013-10-25_*.log 次のコマンドは何も返さないか、単に機能しませんfindstr nfct255c9a d:\comp1\logs\quantum_2013-10-25_*.log