Fast way to recursively delete large amount of files.

From munkjensen.net/wiki
Revision as of 19:17, 25 April 2018 by Admin (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Create an empty directory i the same folder as the one that contains the large amount of files you want to delete.

mkdir empty_dir

Then execute this command:

rsync -a --delete empty_dir/    yourlargedirectory/

This command will grab everything in the directory "yourlargedirectory" and 'archive' it in "empty_dir" if a version of that already is there, else it will be deleted. This is remarkably faster that using the otherwise well known command

rm -rf yourlargedirectory/