我有一個Emacs的功能(fgf "thing")
創建一個子進程,看起來像這樣:排除.svn文件從git的查找文件+ xargs的grep的+管
find . \(-type f -a \! -regex '\.(svn|git)' \) -print0 | xargs -0 grep -nH -e 'thing'
基本上我不想grep
看任何.git
或.svn
文件的。我怎樣才能做到這一點?
我有一個Emacs的功能(fgf "thing")
創建一個子進程,看起來像這樣:排除.svn文件從git的查找文件+ xargs的grep的+管
find . \(-type f -a \! -regex '\.(svn|git)' \) -print0 | xargs -0 grep -nH -e 'thing'
基本上我不想grep
看任何.git
或.svn
文件的。我怎樣才能做到這一點?
find . -type d '(' -name .svn -o -name .git ')' -prune -o -type f -exec grep -nH -e 'thing' {} +
使用-prune
避免遞歸到.svn
和.git
目錄比使用正則表達式更好。另外-exec
優於-print0 | xargs -0
。
什麼不符合您發佈的命令? – 2013-04-08 15:52:19