find . -name ‘*.py’ | xargs rm

2012-01-15   

Trying to remove any doubt which Django Python code I’m using I wrote:

find . -name ‘*.py’ | xargs rm

And as the result I lost all python source files from current directory and all directories below.

I should use:

find . -name ‘*.pyc’ | xargs rm 

One small ‘c’ letter makes the difference between intended removal of compiled Python code and the removal all source Python files in current directory and all directories inside it.

The lesson is to think before pressing enter one might think.

Well, it is one of lessons but there is more here.

I’ve restored all lost files using mercurial.