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

Popular posts from this blog

City Code Table for Casio SGW300HD-1AV Watch

How to force only 4G or LTE network connection for Samsung Galaxy Note 4

Mounting NFS share directory from D-link DNS 320L on Ubuntu 12.04 LTS