Linux下防止文件误删除的工具

时间:2020-09-15 21:10:51   收藏:0   阅读:17
#!/bin/bash
################ README INFO ######################

Purpose: Remove files to a speciel folder

Made By: PomanTeng

E-mail: 1807479153@qq.com

WeChat: 1807479153

Version Identification Number:V0.00

Procedure Identification Number:20200901

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

Declare User-Functions

movetotrash(){

if?[?"$1"?!=?""?];then

\mv?$@?/data/.trash/

else

echo?"rm filename"

fi

}

recoveryfile(){

if?[?"$1"?!=?""?];then

path=pwd
cd?/data/.trash/

\mv?-i?$@?$path

cd?-?>/dev/null?2>&1

else

echo?"command:ur filename"

echo?"-------file list--------"

rl

fi

}

The Business Logic

mkdir?-p?/data/.trash

alias?del="/bin/rm -fr /data/.trash/*"

alias?rm=movetotrash

alias?rl="ls /data/.trash"

alias?ur=recoveryfile

技术图片

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2
迷上了代码!