Quantcast
Channel: Admins Goodies » rm
Viewing all articles
Browse latest Browse all 10

Unix magic, delete all .pyc files from a tree of directories?

$
0
0

Question

Is there a quick way of deleting all the .pyc files from a tree of directories?

Answer

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.


Viewing all articles
Browse latest Browse all 10

Trending Articles