![]() |
ubuntu.com - launchpad.net - ubuntu help
|
|
|||||||
|
The Community Cafe The Community Chat area is for lighthearted and enjoyable discussions, like you might find around a water cooler at work. Almost any non-tech-support topic may be discussed here. Discussions on religion and politics are not allowed, except for politics directly related to free and open source issues. Any topic or discussion that causes problems or drama will be closed. This area is intended for fun and community building, not arguments. Please take those elsewhere. Thanks! |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Just Give Me the Beans!
![]() Join Date: Mar 2008
Location: Melbourne, AU
Beans: 71
Ubuntu 8.04 Hardy Heron
|
Hello everyone. I've just written a shell script for moving files to the "Garbage bin". So unlike the "rm" command, you can retrieve files deleted by mistake on the command line simply by opening the garbage bin.
Code:
#!/bin/bash
until [ "$#" = "0" ];do
mv $1 "$HOME/.local/share/Trash/files"
shift
done
Since there's a loop, I'm able to operate on multiple files and/or folders. It's quite useful I think. Last edited by george9233; June 24th, 2008 at 03:03 PM.. |
|
|
|
|
|
#2 |
|
5 Cups of Ubuntu
![]() Join Date: Dec 2007
Beans: 29
Ubuntu Karmic Koala (testing)
|
Re: A shell script for moving your files to "Garbage bin"
Thanks dude! I took the liberty of improving on it slightly, so the metadata (deleted when, and where from) are also stored: http://keeshink.blogspot.com/2009/10...-to-trash.html
|
|
|
|
|
|
#3 |
|
Fresh Brewed Ubuntu
![]() Join Date: Mar 2009
Beans: 1,527
Ubuntu 9.10 Karmic Koala
|
Re: A shell script for moving your files to "Garbage bin"
It's easy to make.
|
|
|
|
|
|
#4 |
|
Ubuntu Extra Shot
![]() Join Date: May 2007
Location: Canada
Beans: 352
Ubuntu 9.04 Jaunty Jackalope
|
Re: A shell script for moving your files to "Garbage bin"
You can simplify your script even more by making it:
Code:
#!/bin/bash mv "$@" "$HOME/.local/share/Trash/files" |
|
|
|
|
|
#5 |
|
Ubuntu Pale Lager
![]() Join Date: Feb 2007
Location: romania
My beans are hidden!
Ubuntu Development Release
|
Re: A shell script for moving your files to "Garbage bin"
hhhm, reinventing the wheel?
Code:
trash path/to/file Code:
man trash |
|
|
|
|
|
#6 |
|
5 Cups of Ubuntu
![]() Join Date: Dec 2007
Beans: 29
Ubuntu Karmic Koala (testing)
|
Re: A shell script for moving your files to "Garbage bin"
@bigboy: this doesn't create the info file.
@sisco: i found the app in the 'trash-cli' package, thanks for pointing this out! |
|
|
|
|
|
#7 |
|
Ubuntu Extra Shot
![]() Join Date: May 2007
Location: Canada
Beans: 352
Ubuntu 9.04 Jaunty Jackalope
|
Re: A shell script for moving your files to "Garbage bin"
You're right. I had just looked at the first command, noticed it could be simplified, and thought it might be good to give a shorter version. I hadn't even thought about the mechanics of the trash bin or checked the other script. Sorry about that.
Now that you've mentioned it and I've looked at the link for the second version of a trash script and the source for trash-cli and I don't really think it's a good idea to write or use custom scripts to modify the trash bin since the trash applet will change over time and using custom trash scripts can corrupt it. trash-cli doesn't appear to be sharing code with the applet. If it were, I'd feel differently about it. If a person knows about the location of trash files and how to clear it when it's corrupt then doing that might not be so bad. Last edited by bigboy_pdb; October 6th, 2009 at 11:14 PM.. |
|
|
|
| Bookmarks |
| Tags |
| shell script |
| Thread Tools | |
| Display Modes | |
|
|