How do I remove all .pyc files from a project?

I've renamed some files in a fairly large project and want to remove the .pyc files they've left behind. I tried the bash script:

 rm -r *.pyc

But that doesn't recurse through the folders as I thought it would. What am I doing wrong?


find . -name "*.pyc" -exec rm -f {} ;

如评论中所述,您也可以使用-delete操作

find . -name *.pyc -delete

find . -name '*.pyc' -delete

当然是最简单的。


In current version of debian you have pyclean script which is in python-minimal package.

Usage is simple:

pyclean .
链接地址: http://www.djcxy.com/p/4126.html

上一篇: 如何在Bash中的分隔符上分割字符串?

下一篇: 如何从项目中删除所有.pyc文件?