Find And Remove the Files in Unix

Using find command, we can find and remove the specific files. Use the below command to perform such operations.

Ex:

find . -type f -name “testing1.txt” -exec rm -f {} \;

See below examples for more reference.

First, we are searching the files “testing1.txt” using find command and we could see that the file is present under “rrr” directory.

Next, we have used the above command to find the file “testing1.txt” and remove the file.

After executing the command, again searching the same file to confirm whether the file removed successfully or not. In the final search we don’t find the removed file and hence the file have been removed successfully using the find command.