Sometimes you may need to erase some given type of files or with a given extension from a directory and its child directories.

This can also work in some other ways, that I will also show you in this posts.

To achieve this try this command. <p class="codigo">find /directory/where/to/delete -name ‘*.ext’ -exec rm ‘{}’ +</p>

You may also use it to delete files with a given filename.

find /path/to/working/directory -name 'Aerosmith*' -exec rm '{}' +

The above example would delete all files starting with Aerosmith, this may be used to erase all mp3 files that start with Aerosmith, but do you really want to do that :).

you can also use the find command with exec option, to do some other things, like to change permissions to files.

find /tmp/ -name '*.txt' -exec chmod o+w '{}' +

This will make all .txt files in /tmp/ and subdirectories, writable by others (rest of the world).