Custom Command Line Recycle Bin - Printable Version +- Linux Lite Forums (https://www.linuxliteos.com/forums) +-- Forum: Development (https://www.linuxliteos.com/forums/forumdisplay.php?fid=7) +--- Forum: Scripting and Bash (https://www.linuxliteos.com/forums/forumdisplay.php?fid=32) +--- Thread: Custom Command Line Recycle Bin (/showthread.php?tid=6475) |
Custom Command Line Recycle Bin - jack action - 10-01-2019 I've made a script to put a file or folder into a recycle bin instead of a deleting it with rm (which could be problematic if you make an error). In a file called usr/bin/trash, I've put the following: Code: #!/bin/bash Then I created 2 aliases: Code: alias rm="trash" When using rm, you actually put a file or folder into a __trash__ folder within the same directory. (Note: it will overwrite a pre-existing file of the same name previously 'deleted') In case of a mistake, just move the file out of the __trash__ folder. When using empty-trash, you delete all __trash__ folders on the computer. You need root privilege to do so. You could make a Cron job to empty-trash regularly. Re: Custom Command Line Recycle Bin - Marmaduke - 09-14-2020 I like the look of this. I'm an user of rm and always have to stop myself from just banging to command out to makesure I don't do anything stupid. |