I have a Cpanel login of remote system into which I have uploaded a number of folders and files scattered throughout the structure.

But I remember that I did this a few minutes ago, roughly x minutes ago.

Now using ssh and logging into remote terminal of the system (to which I have uploaded files to) how can I find out which files were uploaded x minutes ago and remove them safely without altering any older files and directories ?

Any suggestions ?


find /path/to/directory -type f -cmin -20

This will display all files created less than 20 minutes ago. If the list looks good, add -delete to the end to permanently erase these files.

Additionally, if you want to see files that were modified X minutes ago (eg if you overwrote some files), you can change -cmin to -mmin.

  • with -delete if it says Directory not empty then any other parameter to overcome this ? – Vicky Dev Nov 3 '16 at 10:21
  • This probably means that the directory wasn't emptied by the find, so there is some file in the folder that didn't match the -cmin requirement. Please try again with the -type f parameter I forgot to add on; this might leave you with some empty directories, but should satisfy deleting the files at least. – Iskar Nov 3 '16 at 10:30
  • or use -depth... – Jeff Schaller Nov 3 '16 at 11:02

First run this command and verify the files:

find /path/to/directory -type f -cmin -20

Once the files are displayed correctly, then use the following command to find & delete.

IMPORTANT: Give a correct path to the following command, giving wrong path, can screw your system.

find /path/to/directory -type f -cmin -20 -exec rm -rfv {} \;   ##without confirmation 

find /path/to/directory -type f -cmin -20 -exec rm -riv {} \; ##with confirmation .
  • please format your code for better readability of your answer. – Vicky Dev Nov 3 '16 at 11:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.