How to find and delete files using command in Linux

How to use the command line in Linux to perform find/search and delete files.
Find files with a search term (wildcard is *) and remove them.
find . -name "search term" -exec rm -f {} \;
Before running the command verify the results of the find command by running just
find . -name "search term"

Examples:

Find all files having .txt (*.txt) extension in the current directory and remove them:
find . -type f -name "*.txt" -exec rm -f {} \;
Find all files having .txt (*.txt) extension in the current directory and remove them with confirmation:
find . -type f -name "*.txt" -exec rm -i {} \;

References, Sources and Credits:

http://www.cyberciti.biz/faq/linux-unix-how-to-find-and-remove-files/


Comments