2012-02-02 27 views
6

Czy mogę uruchomić to w wierszu polecenia systemu Windows, tak jak mogę uruchomić go w systemie UNIX?Odpowiednik polecenia systemu Windows egrep

egrep -wi 'FRIENDS|FOES' *.sql 

Polecenie to służy do skanowania każdego pliku SQL dla wszystkich słów kluczowych "Przyjaciele" i "Wrogowie", ignorując przypadek.

+3

Pan spojrzał na polecenie findstr ? http://technet.microsoft.com/en-us/library/bb490907.aspx – selbie

+2

Dlaczego to pytanie jest odrzucane? W systemie Windows CLI brakuje niektórych funkcji, które nas, schronienia dla systemu Linux, biorą za pewnik. – dotancohen

Odpowiedz

3

myślę komenda findstr jest uzasadniona wystarczająco substytut polecenia systemu Windows zamiast Linux.

2

Zależy od systemu. Czy masz zainstalowaną wersję grep? Windows nie ma żadnej wartości grep po wyjęciu z pudełka, ale możesz zainstalować Cygwin/GnuWin lub unxutils.sourceforge.net.

5

Cóż można mieć cygwin na Windows, więc potem trzeba bash, grep itp

Jeśli trzeba tylko grep, to istnieje GnuWin32.

Jeśli nie chcesz niczego instalować i używasz Win XP, spróbuj findstr, chociaż nie możesz tego zrobić "orring".

Jeśli jesteś na Win-7, to jest powershell, z select-string.

2

odpowiednik Windows będzie polecenie FIND:

 
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. 

Ale można też pobrać większość narzędzi uniksowych (w tym grep.) Z http://gnuwin32.sourceforge.net/ (tylko upuść do PATH i korzystania z nich).

2

nie jestem pewien co do lub stanu, ale podstawową cechą powinna wyglądać

type *.sql | find /n "FRIENDS" 
0

Oto odpowiednik egrep "string1 | łańcuch2 | String3":

PS: C:> findstr/C: łańcuch1/C: łańcuch2/C: String3

Powiązane problemy