1. 程式人生 > >grep不查詢有些資料夾

grep不查詢有些資料夾

使用 --exclude-dir 選項

語法

--exclude-dir=DIR Exclude directories matching the pattern DIR from recursive searches.

單個目錄示例

grep -E "http"  ./ -R --exclude-dir=.git 

多個目錄示例

grep -E "http"  . -R --exclude-dir={.git,res,bin}

多個檔案示例

附贈一個,排除副檔名為 java 和 js 的檔案

grep -E "http"  . -R --exclude=*.{java,js}