Sign up ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

How can I empty the trash from the Terminal?

share|improve this question

4 Answers 4

up vote 22 down vote accepted

Another solution would be to create AppleScript containing the folowing code

tell application "Finder"
    empty the trash
end tell

save it as emptytrash for example and execute it via open

or even better (as suggested by Chris) - execute:

osascript -e 'tell app "Finder" to empty'

Since trash is a Finder thing, this should be more compatible in the long run.

share|improve this answer
Directly from the command line: osascript -e 'tell app "Finder" to empty' (though you may want to put in a shell script to avoid having to get the syntax exactly right each time). – Chris Johnsen Mar 25 '11 at 5:56

Trash is actually a hidden folder in the user's folder named .Trash

If you delete it's contents, you empty the trash. You can use

rm -rf ~/.Trash/*

Just be careful with it so you don't delete something else ;)

share|improve this answer
But this will not delete .Trash on mounted media/network volumes. – mspasov Mar 24 '11 at 16:04

A review of various command line tools, for managing the Trash from command line:

share|improve this answer
+1 Good article. – mspasov Mar 24 '11 at 16:13

If you have Homebrew installed, you can easily install trash by typing:

brew install trash

Then, to empty the trash, you only have to type the following from the command line:

trash -e

It's a pretty little piece of software.

$ trash
usage: trash [-ulesv] <file> [<file> ...]

  Move files/folders to the trash.

  Options to use with <file>:

  -a  Use system API for trashing files instead of asking
      Finder to do it. (Faster, but the 'put back' feature
      in the Finder trash will not work if files are trashed
      using this method.) Finder is still used for trashing
      files you have no access rights for.
  -v  Be verbose (show files as they are trashed, or if
      used with the -l option, show additional information
      about the trash contents)

  Stand-alone options (to use without <file>):

  -u  Check for updates (and optionally auto-update self)
  -l  List items currently in the trash (add the -v option
      to see additional information)
  -e  Empty the trash (asks for confirmation)
  -s  Securely empty the trash (asks for confirmation)

  Options supported by `rm` are silently accepted.

Version 0.8.5
Copyright (c) 2010 Ali Rantakari,
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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