Delete Huge Number Of Files

27 Nov 2013

It is time consuming to delete huge number of files by rm.

rsync is more efficient in doing it.

You need to create an empty directory first:

mkdir /tmp/empty

and then run rsync:

rsync --delete-before -a -H -v --progress --stats /tmp/empty /path/to/your/dir

You are expected to get tremendous performance improvement.

But rsync is not more efficient thent rm in deleting a file huge in size.

The recommended tool is echo.

You can delete the content of a file by echo nothing to it:

echo > /path/to/your/file