# trash emtying terminal command



## drgreg (Jan 12, 2003)

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


----------



## symphonix (Jan 13, 2003)

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


----------



## gatorparrots (Jan 13, 2003)

Install this script, name it 'trash' and then you can just type 'trash' to empty your trash:
http://www.macfora.com/forums/showthread.php?postid=109286#post109286


----------



## Giaguara (Jan 13, 2003)

need a script for that?? 

rm -rf ~/.Trash/*

or

sudo rm -rf ~/.Trash/*


----------



## roger (Jan 14, 2003)

it is good advice to script any command string involving sudo, rm and *. It only takes a slip to trash your entire system.

R.


----------



## gatorparrots (Jan 14, 2003)

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.


----------



## Giaguara (Jan 14, 2003)

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..


----------



## gatorparrots (Jan 14, 2003)

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?


----------



## Giaguara (Jan 14, 2003)

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/*


----------



## d1taylor (Jan 14, 2003)

no, if you type 'trash' in the middle of a command, then it'll be an argument to the command:
	
	



```
echo "this is a" trash "test"
```
will not, for example, invoke the *trash* script, Giaguara.


----------

