2012-02-02 115 views
6

我可以在Windows命令提示符下運行此命令,就像我可以在UNIX中運行它一樣嗎?Windows命令相當於egrep

egrep -wi 'FRIENDS|FOES' *.sql 

該指令旨在掃描每個SQL文件爲整個關鍵字「朋友」和「仇敵」,不區分大小寫。

+3

你有沒有看findstr命令? http://technet.microsoft.com/en-us/library/bb490907.aspx – selbie 2012-02-02 08:31:01

+2

這個問題爲什麼downvoted? Windows CLI缺少我們Linux避難所認爲理所當然的一些功能。 – dotancohen 2012-03-01 10:12:01

回答

3

我覺得findstr命令到位Linux的一個很公平的替代Windows命令。

5

那麼你可以在Windows cygwin,那麼你有bashgrep

如果您只需要grep的,再有就是GnuWin32

如果你不想安裝任何東西,並且在Win XP上,請嘗試findstr,儘管它不能做「orring」。

如果你在Win-7上,那麼有powershellselect-string

2

在Windows相當於將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. 

但你也可以從http://gnuwin32.sourceforge.net/下載大部分的UNIX實用程序(包括grep的。)(只是拖放到你的路徑並使用它們)。

2

我不確定有關OR條件,但基本功能應該像

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

這裏是egrep命令一個相當於 「字符串1 |字符串2 | STRING3」:

PS:C:> FINDSTR/C:字符串1/C:字符串2/C:STRING3