Recently I discovered a set of command line tools that allow you to interact with the trash can: trash-cli. Normally only GUI file managers like Nautilus will use the trash can, if you delete files on the command line using rm or rmdir the trash can is bypassed and files are deleted immediately.
With trash-cli you get several commands:
trash-put- to remove files by sending them to the trash cantrash-list- to list the content of the trash cantrash-restore- to restore filestrash-empty- to purge old files
In Ubuntu Intrepid and Jaunty there is an older package of trash-cli, but the authors are not recommending it (too bad the latest version was not packaged for Jaunty). The current installation instructions are really easy:
$ sudo easy_install trash-cli
An interesting application is to automatically purge older items from your trash can. The following command will purge files older than a week:
$ trash-empty 7
If you add this command to your crontab then you don't have to worry about emptying your trash anymore. The following crontab line will run the trash-empty command every hour:
13 * * * * /usr/local/bin/trash-empty 7
While the above is really easy to install and works nice, there are a few things that could be improved.
It would be nice if trash-empty listed the files it purged so they can be appended to a log file. You can achieve this by listing the trash before and after emptying it, and diffing the two list, but that is a bit too much.
Currently the only way to empty the trash is by specifying a number of days. I'm sure some people would prefer to set a maximum size for the trash can.
Technorati Tags: 



No comments yet
Post new comment