How can I empty the trash from the Terminal?
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
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.
A review of various command line tools, for managing the Trash from command line:
brew install trash
Then, to empty the trash, you only have to type the following from the command line:
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, http://hasseg.org/trash