trash emtying terminal command

drgreg

Registered
several months ago some kind soul posted a very useful bit of information to this forum about how to write a little app that you could run under terminal to empty your trash when it was reluctant to do so.

i followed the instructions and wrote the little app and stored it in a folder called "bin" in my home folder. i used it occasionally and it worked well.

last time i went to use it i found it was gone. all i can think is that it was removed somehow when i installed jaguar....

anyway, that mystery aside, can someone post the text of that again - and also instructions on how to make it executable... ar ethese things archived somewhere here?

thanks
 
cd ~/.Trash
sudo rm -rf *
cd /.Trashes
sudo rm -rf *

Save this as a text file. If you give it a .term extension you can double click it and it will run in terminal
 
it is good advice to script any command string involving sudo, rm and *. It only takes a slip to trash your entire system.

R.
 
Did you look at the script and see what it does? It empties all trashes on all volumes in one sweep (with root privileges), as well as getting rid of the cosmetic glitch of the Finder showing a full trash can despite it being empty.

It is much better than simply issuing an rm command.
 
why did he need so many lines to do such a simple script???

i have a command "google" in terminal so i can google from there. but i so far avoid doing a script called "trash" .. typing about 20 chars to empty the trash is not too uncomfortable. what i dont understand is why emptying trash from the dock it takes ages and ages to become empty..
 
The beauty of his script is that it will force empty the trash (as root) on all volumes. If you have a 'stuck' file that the Finder won't delete, this will take care of it. Also, it is much, much faster to simply type 'trash' in the Terminal and enter your admin password than to empty a trashcan that has many files in it (as you have experienced).

I could write a quick AppleScript wrapper for his script, if you want a double-clickable GUI application to avoid the trip to the Terminal. Anyone else interested in this?
 
if i had that script, in case i need to type trash in terminal in a middle of a command, it goes to delete the items in trash . .. and in all the cases that is not what i probably intended to do while i was typing trash, i could do something else and have that word in the middle of a command. so i either type the one line command manually of even lazier, keep it on a sheet on notes and cut and paste whenever i need to empty it. [graphical mode is too slow]
so,

sudo rm -rf ~/.Trash/*
 
no, if you type 'trash' in the middle of a command, then it'll be an argument to the command:
Code:
echo "this is a" trash "test"
will not, for example, invoke the trash script, Giaguara. :)
 
Back
Top