 |
 |
Move file to trash from Terminal
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2000
Location: Edmond, OK USA
Status:
Offline
|
|
Is there a command-line way to get a file into the trash? Also, can I secure-delete the trash contents from the command line?
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Dec 2001
Location: Atlanta, GA, USA
Status:
Offline
|
|
To move a file to the trash:
Code:
mv <somefile> ~/.Trash/
To secure-delete a file, use srm. It works like "rm" but has more options for secure delete.
|
|
Mac Pro 2x 2.66 GHz Dual core, Apple TV 160GB, two Windows XP PCs
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Mar 2004
Status:
Offline
|
|
I would suggest writing a shell script to do this automatically... so you could just use "trash foo"
|
|
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Jan 2004
Status:
Offline
|
|
Originally posted by Turnpike:
I would suggest writing a shell script to do this automatically... so you could just use "trash foo"
FWIW, I just added a trash() function to my start-up file--in my case, .zshenv.
trash() { mv "$@" ~/.Trash; }
Of course, you can tweak as necessary. For example, I use this to collect all the .mp3s and send to trash:
trashmp3() { find . -iname '*.mp3' -exec mv {} ~/.Trash \; }
I ain't no expert but it works for me ;-)
HTH,
Uber
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2000
Location: Edmond, OK USA
Status:
Offline
|
|
Thanks to everyone - I think what I will do is alias trash to move files into the trashcan, and also create an alias to secure emtpy the trash from the command-line - that should work well.
Thanks all!
|
|
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Jul 2001
Location: NC
Status:
Offline
|
|
Scripts to move items to trash have already been written. I call my own rmm because it emulates the behavior of rm. It supports all of the same options and responds in the same way. The main difference is that it moves the files to trash instead of unlinking them. It uses 'ditto" to make the move so that resource forks are preserved. That way, if you make a mistake and want to pull items out of trash, they will still have their resource forks. Otherwise, some files would be rendered useless by the move to trash anyway.
If you download the script, you should get the one called rmm. The page linked to above is a little out of date; the rmm script has been thoroughly tested.
|
|
Gary
A computer scientist is someone who, when told to "Go to Hell", sees the
"go to", rather than the destination, as harmful.
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|