9

On a Mac computer, when you write

 rm -rf ~/.Trash/*

in the terminal, it almost instantly deletes all the files in the Trash.

But when I click "empty trash", it takes forever to delete them all.

  • Have you set securely empty trash or an equivalent feature on? If so, the command is as Claudio says which the GUI could be doing a hook that does a zero-out pass. – nerdwaller Mar 7 '13 at 3:32
  • How long is forever? How many files do you have? It could just be that the GUI is stuttering on updating the UI if you have tons of small files. If naively implemented, the UI could remove one icon per file deleted from the filesystem, which is slow. – beatgammit Mar 7 '13 at 5:46
6

When you use rm -rf ~/.Trash/* you're directly using a system call that unlinks these files from the filesystem, freeing the space allocated by them. If you use a GUI tool instead (I suppose you are referring to it when you say "click empty trash") it is probably saving or moving these files somewhere else so you can possibly undelete them, which is not directly possible using the shell command line. That should be the reason it is faster, but it wouldn't explain the GUI tool taking "forever".

How many times faster do you perceive the command line erase comparing to the GUI tool?

  • 1
    The command line would be less than 5 seconds. Compare that to the GUI tool, which would take sometimes 3-5 minutes to empty everything. This is for about 1.5GB of files. – averageUsername123 Mar 10 '13 at 2:30
  • Can also confirm that emptying via the GUI is a few orders of magnitude slower than via rm -rf. – Paul Razvan Berg Dec 25 '19 at 16:08
  • This answer, speculating that emptying the bin on macOS doesn't actually delete things, but is actually like putting stuff into the bin, misunderstands what the bin does. Perhaps this might have to do with a difference between 'bin', 'trash', and 'recycle bin' over different OSes, but they all describe the same thing. Speculation should at least be in the right ballpark to receive an upvote. – ifly6 Dec 10 '20 at 12:35
  • @ifly6, instead of speculating how much people know about what they say, have you actually used any kind of Unix-like system and their associated GUIs to actually explain what happens under the hood instead of debating how much someone deserves and upvote or something else? Your own answer would be much more appreciated, maybe even useful. – Claudio Dec 12 '20 at 20:36
  • If you use a GUI tool instead (I suppose you are referring to it when you say "click empty trash") it is probably saving or moving these files somewhere else so you can possibly undelete them is internally inconsistent. Resolve that issue in your answer. – ifly6 Dec 12 '20 at 20:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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