Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个 Emacs 函数(fgf "thing"),它创建一个如下所示的子进程:
(fgf "thing")
find . \( -type f -a \! -regex '\.(svn|git)' \) -print0 | xargs -0 grep -nH -e 'thing'
基本上我不想grep看任何.gitor.svn文件。我怎样才能做到这一点?
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。
-prune
-exec
-print0 | xargs -0