How to find certain files and delete them with a single command

Yesterday, while my Dropbox was updating, it created hundreds of “conflicted files” scatterred around many directories, so I turned to the command line to search them and delete them all at once

find . -type f -name "*confli*" -exec rm -i -f {} \;

I had to use the -f option because I didn’t want to confirm each file, and I did a previous

find . -type f -name "*confli*"

before so nothing to worry about. This command can be used to search and recursively delete files, just change the “*confli*” to anything you want, like “*.txt”

Comments are closed.