Simple Command Line Trash


Simple Command Line Trash

by Christopher Kaukis

Do you hang out on the command line a good amount of time? Do you execute rm [-rf] on a regular basis? Have you ever wished that the file was moved to the trash instead (when you realize it at a later time of course)? Well, I have. So, I wrote a quick bash script called “trash” and threw it in my ~/bin folder and made it executable. This is the entire contents of the file (it’s all I need at this time):

mv $* ~/.Trash

Copy and paste this into a file, call it whatever you want, make it executable (chmod + x), and make sure you save it to someplace in your path.

Two things, I’m on Mac OS X, so this probably won’t work in Windows (who would hang out on the Command Prompt, ew). I’ll have to get used to typing `trash` instead of `rm` (the hardest part).

It’s useful if you use rm on the command line a lot, but end up re-downloading the same thing again later (I don’t know why, but I do). This just saves me the time of going back to re-download later. At least that’s the idea behind this script, for now.

KeepWatch by InterWorks

Whether you need support for one platform or many, our technical experts have you covered.

More About the Author

Christopher Kaukis

Software Engineer
Running a Jekyll Blog Using Github Pages on Mac OS X 10.8 Mountain Lion In my last post I described installing Ruby on Mac OS X with RVM. The main reason I wanted to do this was to run a Jekyll Blog using ...
Installing Ruby 2.0.0 with RVM and Homebrew on Mac OS X 10.8 Mountain Lion This is a tutorial on how to install Ruby 2.0.0 on Mac OS X 10.8 Mountain Lion.  1. Install Xcode and the Command Line Tools If you ...

See more from this author →

InterWorks uses cookies to allow us to better understand how the site is used. By continuing to use this site, you consent to this policy. Review Policy OK


Interworks GmbH
Ratinger Straße 9
40213 Düsseldorf
Geschäftsführer: Mel Stephenson

Telefon: +49 (0)211 5408 5301

Amtsgericht Düsseldorf HRB 79752
UstldNr: DE 313 353 072


Love our blog? You should see our emails. Sign up for our newsletter!