See a post today, tell me how to recover the data after it was mistakenly deleted. In the back of the thread found a more interesting thing, his exact words are like this:
I thought it was fun, so I decided to try it out myself.
First to build a directory to do the Recycle Bin, I chose to build a trash hidden folder in the root directory as the Recycle Bin: mkdir/.trash
Take a look at the established Recycle Bin: ll-a/|grep. Trash
Then I checked the MV usage: Man mv. Inside, there is such a parameter
This makes it obvious that I need to replace "rm *" with "mv-t/.trash-i *" And then I'm done. Since you are prepared to define your own commands, of course, Alias:alias rm= ' mv-t/.trash-i '
Then we look at the list of alias: Alias This is the new one added.
Let's try it. Create a new file: Touch test.test, then delete it with RM: RM test.test. LS view, found that test.test is really missing, then is not moved to the Recycle Bin "/.trash", go to see it: LS/.trash sure in the Recycle Bin.
At this point, the functionality has been implemented. But think of a question, what if I really want to delete a file? I try to delete files from the Recycle Bin: RM/.trash/test.test get boost MV: "/.trash/test.test" and "/.trash/test.test" are the same file. This can be troublesome, is it possible to delete files every time only through the/bin/rm to achieve it? Forget it, pound, simply add a custom command: Alias rrm= '/bin/rm-i ' cannot be written as ' rrm= ' rm-i ' because RM has been replaced with ' mv-t/.trash-i '. Then let's try the RRM directive: RRM/.trash/test.test Enter y acknowledgment and finally successfully deleted the Test.test file.
Alias instruction is a single time, the next time the power off after the shutdown, in order to ensure the next power-on command to maintain, we can modify the ~/.BASHRC file. The BASHRC file has the phrase "User specific aliases and functions", We can write the aliases we want to define in this file. The original alias rm= ' Rm-i ' in the file is commented out, plus alias rrm= '/bin/rm-i ' and alias rm= ' Mv-t/.trash-i ' two sentences. OK, now this function will be retained forever ~ ~
Let's get ourselves a recycling station and play.