How to quickly delete a huge number of files/directories

By | January 28, 2014

Recycle bin fullDeleting files/directories might seem a trivial thing to do, but when you have a lot of them, it can take quite a bit.

The biggest problem with this task is the time taken. A simpleĀ rm -rf <path_to_delete>/ can take even a few hours to do the task, while it creates quite a load on the hard disk.

Of course, if you have a separate partition mounted, you can format it, but what happens when you don’t have this option?

Here is a nice trick which does the job quite fast:

mkdir /tmp/deltmp/
rsync -a --delete /tmp/deltmp/ <path_to_delete>
rmdir /tmp/deltmp/

Please note that all the files and directories will be deleted from the desired path (and no, there is no recycle bin!)

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload the CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.