Ever try to delete files with unix shell find? Use the -delete option

command, find, shell, unix

Solution

Here's how to do it with the `-delete` option!

Use the find command option `-delete`:

find . -name '*.pyc' -delete

Of course, do try a dry run without the `-delete`, to see if you are going to delete what you want!!! Those computers do run so darn fast! ;-)

Problem

This has come up a number of times in posts, so I'm mentioning it as a thankyou to all helpful people on stackoverflow. Have you ever wanted to do a bunch of deletes from the command line/terminal in Unix? Perhaps you used a construct like ``` find . -name '*.pyc' -exec rm {} \; ``` Look to the answer for an elegant way to do this.

Original source