Ludicrously Fast File Deletion
Scenario: You have a directory with thousands of files totaling more than 20GB in total storage space. Normally, you might try the good ol':
rm -rf full-directory/
Well, that will work...eventually. If you've got a couple hours to spare it will delete your files. However it is extremely inefficient. So what do we do?
rsync to the rescue:
mkdir empty-directory/
rsync -av --delete empty-directory/ full-directory/
The rsync operation will attempt to synchronize the contents of empty-directory with the full-directory, deleting anything that isn't present in empty-directory. The net benefit for us is that it will delete all of our large files in full-directory ridiculously quickly.
Try it out the next time you need to get rid of a ton of old junk bits.
Written by Michael Gile
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Shell
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#