2009-11-05 3 views

답변

14

일부 옵션 :

  • Grep for Windows - 경량 옵션
  • GNU utilities for Win32 - 기본 포트
  • Cash - 경량, Node.js
  • Cygwin 위에 구축 - 무거운 옵션을 선택합니다. GNU 라이브러리 & 쉘을 포함합니다. 원하는 바이너리와 필요한 파일을 추출하고 수동으로 설치할 수는 있지만 엉망입니다.
+2

또한 dnGREP (http://code.google.com/p/dngrep/)를 추가 할 것입니다. Windows 용 오픈 소스 grep 도구입니다. – stankovski

0

시도해 볼 수 있습니다 Cygwin, 그것은 유닉스 시스템에서 일반적인 명령 줄 도구 모음입니다.

1

한 가지 방법은 Cygwin을 설치하는 것입니다. Cygwin은 POSIX 동작을 시뮬레이트하는 dll을 사용합니다.

유닉스 도구에는 네이티브 프로젝트 인 GnuWin32UnxUtils이 있습니다.

1

설치 Cygwin. 유닉스 에뮬레이터이고 윈도우에서 regex를 사용할 수있게 해줍니다.

3

전체 UNIX 도구 모음 (컴파일러, X 서버, 모두)을 원하면 Cygwin이 좋습니다. Cygwin DLL은 실제로 완전한 유닉스 환경, 명령 행 도구, GUI 도구 및 프로그래밍 환경을 제공하므로 UNIX 소프트웨어를 Windows로 쉽게 포팅 할 수 있습니다.

나는 내가 필요한 것을 추가 할 수 있기 때문에 GnuWin32 (Windows 용 GNU)을 선호합니다. 패키지로 제공되므로 많은 것을 설치할 필요가 없습니다. Cygwin DLL을 필요로하지 않고 Windows 용으로 네이티브하게 컴파일됩니다.

예를 들어, 나는 최근에 특정 빠르고 쉬운 텍스트 파일 조작을 위해 awk가 필요한 상황이있었습니다. 나는 Cygwin 환경 전체를 설치해야하는 것을 당황스럽게 생각했으며 GnuWin32는 훨씬 쉽고 (더 빠르다).

grep의 관점에서 볼 때 Windows findstr은 요즘보다 약간 강력하다는 것을 알고 싶을 것입니다. 요즘에는 정규 표현식을 사용할 수도 있습니다. 아직도 내 사랑하는 UNIX 툴체인 :-)의 후단에 심지어 여드름은 아니지만 필요에 따라 실행 가능한 옵션이 될 수있다 :이 소프트웨어는 과거에 나를 위해 잘 작동하고있다

C:\Documents and Settings\Pax> 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 occurances 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. 
+0

Cygwin에서 설치 한 것을 일부만 선택할 수 있습니다. 설치할 패키지를 선택하십시오 설치 (및 설치 후 제거 등). –

1

Windows에 grep이 없으면 안되는구나. 당신은 언급 한 그들 중 하나처럼 findstr를 사용하거나 그냥 vbscript 프로그래밍을 할 수 있습니다.

패턴 검색의 예 : (grep을 할 수있는 동등한 "단어"파일) 물론

Set objFS = CreateObject("Scripting.FileSystemObject") 
strFile= "C:\test\file" 
Set objFile = objFS.OpenTextFile(strFile,1) 
Do Until objFile.AtEndOfStream 
    strLine = objFile.ReadLine 
    If InStr(strLine,"word")> 0 then 
      Wscript.Echo "Found word: " & strLine 
     End If 
Loop 

, 당신이 당신의 환경에 물건을 다운로드하는 사치는 GNU 그렙를 사용할 수있는 경우 (다른 사람). 배치 스크립팅 환경을보다 쉽게 ​​만들 수 있습니다.

0

chocolatey을 Windows에 설치하면 Gow 도구를 설치할 수 있습니다.
이것은 windows에서 grep을 제공합니다.

Gow은 Windows에서 GNU를 나타냅니다. windowsunix command line utilities을 제공합니다.

관련 문제