Linux prevents Rm-rf from accidentally deleting shell scripts

Source: Internet
Author: User

#!/bin/bash  

#:set Ff=unix

#:set Nobomb

#-*-Coding:utf-8-*-

######################################################################

# # Filename:Trash.py

##

# # Copyright (C) 2014.6

# # Author: [email protected] @qq. com

##

# # Description:shell Prevent RM-RF Accidental deletion  

##

######################################################################

Cat/root/.bash_profile | grep "Trash" &>/dev/null

if [$?-eq 0]# through if The statement determines whether the script has been executed, or if it is executed once, the content is added once  

Then

echo "has been done"

Else

Echo-e "

Mkdir-p ~/.trash

Alias Rm=trash

Alias R=trash

Alias rl= ' ls ~/.trash '

Alias Ur=undelfile

function Undelfile ()

{

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

}

Trash ()

{

MV "\[email protected]"/root/.trash/

} ">>/root/.bash_profile

source/root/.bash_profile #source the document, which took effect  

Fi

# the deleted file is in the /root/.trash in   



Source: http://iotos.iteye.com/blog/2092948



From for notes (Wiz)

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.