1. 程式人生 > >如何在linux中進行全域性按檔案型別搜尋

如何在linux中進行全域性按檔案型別搜尋

結合find命令和grep

首先利用find命令過濾出指定型別的檔案,下面的例子是查詢 "*.c" 和 "*.h" 檔案。

</pre><pre name="code" class="plain">find . -regex ".*\.\(h\|c\)" 
然後將記過
find . -regex ".*\.\(h\|c\)" | xargs grep -Inwr "keyword"
其中xargs是將find得出的檔案列表,分割分批傳送給grep。