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.
findstr
C:\> 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.
1
아마도 진화에 관한 것입니다. 찾기는 DOS / UNIX 시절로 돌아가고 나중에 FINDSTR이 Windows에 추가되었습니다. 둘 다 아마도 진화했고 더 비슷해졌습니다.
—
KCotreau
@KCotreau의 타임 라인에 동의합니다. FIND는 고대이고 FINDSTR은 최신입니다. 나는 FIND가 FINDSTR과 같은 것으로 진화했는지 의심합니다. 오히려 FIND는 이전 버전과의 호환성을 유지하기 위해 (일반적으로 DOS와 마찬가지로) 잔인한 공룡으로 보존되었지만 FINDSTR은 적절한 기능 세트를 제공하기 위해 추가되었습니다 .
—
Scott
그런데 DOS / Windows FIND 명령은 Unix
—
Scott
find
명령 과 다릅니다 . 오히려, paradroid가 아래에서 제안하는 것처럼 FIND는 grep
(또는 아마도 fgrep
) 의 물을 뿌린 버전과 같습니다 .
도움말의 차이점이 보이지 않습니까?
—
phuclv