Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I use the command rm -rf directory but i came across the following article : Article That suggests that rsynch to an empty folder is the fastest way? rsync -a –delete empty/ a Why is this the case ? Is there another faster method to delete a nonEmpty folder ?

Another interesting article about this Article2

share|improve this question

2 Answers 2

up vote 1 down vote accepted

Based on a very quick glimpse at GNU Coreutils 8.21 and rsync 3.0.1 sources plus taking a look what they do with the strace, the rm from GNU Coreutils seems to call malloc() quite a bit more than rsync does when performing the same thing. I'm doubt this explains the speed difference completely, though, but it's part of the explanation most likely.

share|improve this answer

I have found that the fastest and most memory-efficient solution is to use this command in the directory full with millions of files:

ls -f1 | xargs rm


Because ls -f1 will not sort the directory content, it will start the output right away. The rm command will take just one argument: the actual file name coming from the first command. It was the only solution to delete 3.000.000 files from a Magento webshop's session directory. The server ran on a virtual machine with just 2Gb of RAM - it was no other possibility to delete the files.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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