Transform RM commands under Linux to move files to Recycle Bin "go"

Source: Internet
Author: User

Transferred from: http://blog.csdn.net/a3470194/article/details/16863803

[-] Transform the RM command under Linux into a mobile file to the Recycle Bin to transform the RM command under AIX into a mobile file to the Recycle Bin. Transforming the RM command under Linux into a mobile file to the Recycle Bin RM is a command for file deletion under Linux. It is a very powerful but very dangerous command under Linux, especially the RM-rf sometimes strong enough to make you cry without tears, when you want to clear all the files and directories in the current directory, it is simple #rm-rf./* It's nothing, but, but if you accidentally hit it like this #rm-rf/* Brother please my condolences! ~ ~ RM Deletes files while deleting inode information, which makes it very difficult to recover files deleted using RM. In short, RM is too dangerous, especially with-RF parameters must be cautious, but the Tiger also has nap time ah, so why not give RM a dose of regret medicine! After the search on the Internet, I found a section to transform the RM command to move the file to a designated Recycle Bin directory, then you can view the file in the Recycle Bin directory, and then empty the Recycle Bin directory to completely delete the file of a piece of code, this short code of the original source has not been refined, But in the spirit of a single lele is not as many Lele to share it out! Mkdir-p/.trash #创建一个目录作为回收站, where the user's home directory is used. Trash Directory alias Rm=trash #命令别名 RM changed to Trash, The RM command alias value Trash is implemented to transform RM to delete file to Recycle Bin alias R=trashalias rl= ' ls ~/.trash ' # RL command show file in Recycle Bin alias Ur=undelfile # The UR command retrieves the files in the Recycle Bin Undelfile () {mv-i ~/.trash/\[email protected]./} #这个函数的作用是找回回收站下的文件trash () {MV [email p Rotected] ~/.trash/} #这个函数是将指定的文件移动到指定的目录下, by the RM command alias value Trash to convert RM to delete files to the Recycle Bin Cleartrash () {read-p "clear sure?[ N] "confirm [$confirm = = ' Y '] | | [$confirm = = ' Y '] &&/bin/rm-rf ~/.trash/*} #这个函数的作用是清空回收站目录下的所有文件这段代码定义了三个函数trash, Undelfile, and Cleartrash. The role of trash is to move files to the specified Recycle Bin directory, undelfile to retrieve the specified files in the Recycle Bin directory, and Cleartrash to empty the Recycle Bin directory. The RM command alias is trash to implement the RM command transformation! Here is my revised code, created directly in the user's home directory. Trash directory as the Recycle Bin, add other code to the user's home directory under the. bashrc file, so that each time the user logs in this paragraphThe code will take effect automatically! After logging in, execute the following command under Bash to change the RM command to delete files to the Recycle Bin!  Mkdir-p ~/.trashcat >>. BASHRC <<eofalias rm=trashalias rl= ' ls ~/.trash ' Alias Ur=undelfileundelfile () {mv-i ~/.trash/\[email protected]./}trash () {mv\[email protected] ~/.trash/}cleartrash () {read-p "clear sure?[ N] "confirm [\ $confirm = = ' Y '] | | [\ $confirm = = ' Y '] &&/bin/rm-rf ~/.trash/*}eof========================= instance: mkdir-p ~/.trash----Create a file   Clamp for use as a trash bin. Transform the RM command under AIX to move files to the Recycle Bin Mkdir-p/.trash #创建一个目录作为回收站, which is used in the user home directory. Trash Directory alias Rm=trash #命令别名 RM changed to Trash, The RM command alias value Trash is implemented to transform RM to delete file to Recycle Bin alias rl= ' ls ~/.trash ' # RL command show file in Recycle Bin alias ur=undelfile # ur command retrieve file alias in Recycle Bin Cleartrash=cleartrash #命名清楚垃圾桶中所有垃圾 Add the following script to/etc/profile: alias Rm=trashalias rl= ' Ls/.trash ' aliasur= Undelfilealiasrmcls=cleartrash Trash () {MV [email protected]/.trash/} undelfile () {mv-i/.trash/[email  Protected]./}cleartrash () {echo-n "clear sure?[ N] "read i[$I = = ' Y '] | | [$I = = ' Y '] && /BIN/RM-RF/.trash/*}

Transform RM commands under Linux to move files to Recycle Bin "go"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.