Say I have 3 directories .git, .hg and .svn somewhere in the folder called lol.

How can I find and remove all of these?

The following does so only for the last one (.svn):

$ find lol -type d -name .git -o -name .hg -o -name .svn -delete

E: This could be done with ls too but not without shopt -s globstar (since I'm not doing it with zsh):

$ shopt -s globstar
$ rm -r $(ls -d ceaw/**/.{git,hg,svn})

E2: Another solution woulda been:

$ find lol -type d -name .git -o -name .hg -o -name .svn | xargs rm -rf
有帮助吗?

解决方案

Try using the -exec option instead.

find lol -depth -type d \( -name .git -o -name .hg -o -name .svn \) -exec rm -r '{}' \;
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top