Dos命令findstr及fc

來源:互聯網
上載者:User

標籤:findstr   fc   

在分析或編寫代碼的過程中,經常需要在檔案中尋找字串或對兩個檔案進行比較。Linux下常用的命令是grep和diff。Windows下檔案比較有比較好的開源工具,如WinMerge。在檔案中尋找字串不清楚是否有好的開源工具。最近發現windows居然有dos命令可以滿足需求。


findstr:在檔案中尋找字串。

 /S         在目前的目錄和所有子目錄中搜尋匹配檔案。

 /C:string  使用指定字串作為文字搜尋字串。


<b>Examples</b>

01:
findstr "computer help" myfile.txt
輸出myfile.txt中包含computer或help字串的行到dos控制台上。


02:
findstr /s "computer help" *.txt
與上例類似, 在目前的目錄及子目錄txt檔案中尋找包含computer和help字串。


03:
findstr /s /c:"computer help" *.txt
在目前的目錄及子目錄txt檔案中尋找包含“computer help”字串。



fc: 比較兩個檔案或檔案集之間的不同

<b>Examples</b>

fc file1 file2

Dos命令findstr及fc

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.