Script To Remove Files Made Either By Python Or Git

Grant Edwards invalid at invalid.invalid
Fri Oct 9 11:49:38 EDT 2015


On 2015-10-09, Marko Rauhamaa <marko at pacujo.net> wrote:

>>> $ rm $(find . <find-options-go-here>)
>
> This is not safe since find might return pathnames with spaces in
> them.

Good point.

> Also, the command fails if find should produce no matches.

I just tried, it with a pattern that produced no matches, and it
removed no files.  That's what one would expect it to do. I admit the
message from rm is undesirable.  :)

>> Or if you're using GNU find:
>>
>> $ find <find-options-go-here> -delete
>
> This is safe.

Agreed, that is a better answer. I've known for years that gnu find
has a -delete option, but I always forget to _use_ it.

-- 
Grant Edwards               grant.b.edwards        Yow! I'm having a
                                  at               tax-deductible experience!
                              gmail.com            I need an energy crunch!!



More information about the Python-list mailing list