diceline-chartmagnifiermouse-upquestion-marktwitter-whiteTwitter_Logo_Blue

Today I Learned

Fastest way to delete a folder structure in Linux

The problem

Deleting a huge folder structure is a pain and can take forever. However if you want to take forever divided by 3, you can use rsync.

It seems rsync is 3 time faster when deleting a huge folder structure than rm or find because it doesn't read the files before deleting.

The trick

  • Create an empty folder in /tmp/empty_folder
  • Run the command:

rsync -aP --delete ./empty_folder/ ./target_folder/


Enjoy!