8
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

find でのディレクトリの削除

Posted at

元ネタ

これ

シンプルなやりかた

何も考えないでやると

$ find . -type d -name .svn -exec rm -rf {} \;

この方法だと、以下のようにエラーが発生する

find: ./hoge/.svn: No such file or directory
find: ./fuga/.svn: No such file or directory

エラーを取り除く

-prune オプションを追加する。

$ find . -type d -name .svn -prune -exec rm -rf {} \;

効率よく削除する

rm は引数に複数のディレクトリを指定できるが、上記コマンドだと一つづつ指定される。;+ に変更して、マッチしたディレクトリ全体が渡るようにする。

$ find . -type d -name .svn -prune -exec rm -rf {} +
8
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?