我有一个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