interstar Asked: 2009-09-08 03:20:32 +0800 CST2009-09-08 03:20:32 +0800 CST 2009-09-08 03:20:32 +0800 CST Unix magic, delete all .pyc files from a tree of directories? 772 Is there a quick way of deleting all the .pyc files from a tree of directories? unix 3 Answers Voted Best Answer Cian 2009-09-08T03:24:07+08:002009-09-08T03:24:07+08:00 If you've got GNU find then you probably want find <directory name> -name '*.pyc' -delete If you need something portable then you're better off with find <directory name> -name '*.pyc' -exec rm {} \; If speed is a big deal and you've got GNU find and GNU xargs then find <directory name> -name '*.pyc' -print0|xargs -0 -p <some number greater than 1> rm This is unlikely to give you that much of a speed up however, due to the fact that you'll mostly be waiting on I/O. slubman 2009-09-08T03:24:35+08:002009-09-08T03:24:35+08:00 using the command find: find /path/to/start -name '*.pyc' -exec rm -f {} \; Garry Harthill 2009-09-08T03:27:29+08:002009-09-08T03:27:29+08:00 cd to the start of the tree of directories then: find . -name '*.pyc' |xargs rm -f
If you've got GNU find then you probably want
If you need something portable then you're better off with
If speed is a big deal and you've got GNU find and GNU xargs then
This is unlikely to give you that much of a speed up however, due to the fact that you'll mostly be waiting on I/O.
using the command find:
cd to the start of the tree of directories then:
find . -name '*.pyc' |xargs rm -f