Linux RM changed to mobile data to recycle Bin

Source: Internet
Author: User

Transform RM commands under Linux to move files to the Recycle Bin

RM is a Linux file deletion command, it is a very powerful and very dangerous Linux under the command, especially 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 very simple #rm-rf./* It's nothing, but, But if you accidentally hit 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 #创建一个目录作为回收站, using the. Trash directory under the user's home directory

Alias Rm=trash #命令别名 RM changed to Trash, and the RM command alias value Trash to convert RM to delete file to Recycle Bin

Alias R=trash

Alias rl= ' ls ~/.trash ' # RL command to display files in Recycle Bin

alias ur=undelfile # ur command to retrieve files from Recycle Bin

Undelfile ()

{

Mv-i ~/.trash/\[email protected].

} #这个函数的作用是找回回收站下的文件

Trash ()

{

MV [email protected] ~/.trash/

#这个函数是将指定的文件移动到指定的目录下, transform RM to delete file to Recycle Bin by trash the RM command alias value

Cleartrash ()

{

Read-p "clear sure? [N] "confirm

[$confirm = = ' Y '] | | [$confirm = = ' Y '] &&/bin/rm-rf ~/.trash/*

} #这个函数的作用是清空回收站目录下的所有文件

This code defines three functions 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 login this code will automatically take effect! After logging in, execute the following command under Bash to change the RM command to delete files to the Recycle Bin!

Mkdir-p ~/.trash

Cat >> BASHRC <<eof

Alias Rm=trash

Alias rl= ' ls ~/.trash '

Alias Ur=undelfile

Undelfile ()

{

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:

650) this.width=650; "Src=" http://img.blog.csdn.net/20131121170627281?watermark/2/text/ ahr0cdovl2jsb2cuy3nkbi5uzxqvytm0nzaxotq=/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity/ Center "/>

Mkdir-p ~/.trash----Create a folder to use as a trash bin.



Transform RM commands under AIX to move files to the Recycle Bin

Mkdir-p/.trash #创建一个目录作为回收站, using the. Trash directory under the user's home directory

Alias Rm=trash #命令别名 RM changed to Trash, and the RM command alias value Trash to convert RM to delete file to Recycle Bin

Alias rl= ' ls ~/.trash ' # RL command to display files in Recycle Bin

alias ur=undelfile # ur command to retrieve files from Recycle Bin

Alias Cleartrash=cleartrash #命名清楚垃圾桶中所有垃圾

Add the following script to the/etc/profile:

Alias Rm=trash

Alias Rl= ' Ls/.trash '

Aliasur=undelfile

Aliasrmcls=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/*

}


This article is from the IT Network Tanuvi blog, be sure to keep this source http://03301216.blog.51cto.com/4550876/1749924

Linux RM changed to mobile data to recycle Bin

Related Article

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.