Hi Everyone
For frequent rm
users, we know that this can be a tricky command to use on scratch, as it fully deletes files and gives no space for mistake. We were talking about that on CFP’s slack channel, and I shared a workaround I use - maybe that could be useful for y’all too…
Simply put, you can create an alias that mimics rm
, but actually moves the data to a trash folder on scratch, and then set up an automatically daily cleaning of that trash folder. This gives a few hours to fix rm mistakes.
The alias I use is:
alias rmt="mv -t /target/directory/with/created/trash/folder/ "
Then for the folder cleaning, I program to clean any file that has not been changed in more than 5 days:
find /target/directory/with/created/trash/folder -mindepth 1 -ctime +5 -delete
That works cause mv
alters the change timestamp of the file. Since bash_profile is read at ssh login, it should work as long as you are regularly SSH’ing gadi.
If you want the alias to be a substitute to rm, to make rm safe, you can instead:
alias rm="mv -t /target/directory/with/created/trash/folder/ "
Hopefully that is useful for others And feel free to suggest improvements!