Home Ask Login Register

Developers Planet

Your answer is one click away!

Li'l Help Please February 2016

How to delete selected files from the command line

I have a shell command that I run to scan my server and list all files with the name temp_file_14 in the /home directory tree as follows:

find /home . -name "temp_file_14" -exec ls -lh {} \;

I would like to change this command to have it physically delete the "found" files instead of listing them. Can someone help me with what the command should look like to perform a delete task instead of a list task?



Akceptor February 2016

This should work:

find . -name "temp_file_14" -exec rm -rf {} \;

Or this one:

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

Post Status

Asked in February 2016
Viewed 3,372 times
Voted 12
Answered 1 times


Leave an answer

Quote of the day: live life