Delete files with a pattern recursively using the terminal

terminal

This is just a simple way to delete files recursively using your terminal in any UNIX-like operating system:

find . -type f -name "FILES_PATTERN" -exec rm {} \;

// Example
find . -type f -name "*.mp3" -exec rm {} \;

Explanation

-name “FILES_PATTERN” : File pattern.
-exec rm -rf {} \; : Delete all files that match the file pattern.
-type f : Not include directories.

Añade un Comentario

Leave a Reply

Your email address will not be published. Required fields are marked *