Convert RM command to MV Command, cannot use the-R parameter, will report an error, because the MV command does not have the-R parameter, the following is the method:
#设置别名, RM is delete file, RL is view Recycle Bin, ur is recovery file
Alias rm= ' Trash '
Alias Rl= ' Trashlist '
Alias ur= ' Undelfile '
#替换rm指令移动文件到 ~/.trash/.
Trash ()
{
MV [email protected] ~/.trash/
}
#显示回收站中垃圾清单
Trashlist ()
{
Echo-e "33[32m==== garbage Lists in ~/.trash/====33[0m"
ECHO-E "\a33[33m----Usage------33[0m"
Echo-e "\a33[33m-1-use ' cleartrash ' to clear all garbages in ~/.trash!!! 33[0m "
Echo-e "\a33[33m-2-use ' ur ' to mv the file in garbages to current DIR!!! 33[0m "
Ls-al ~/.trash
}
#找回回收站相应文件
Undelfile ()
{
Mv-i ~/.trash/[email protected].
}
#清空回收站
Cleartrash ()
{
Echo-ne "\a33[33m!!! Clear all garbages in ~/.trash, sure? [y/n]33[0m]
Read confirm
if [$confirm = = ' y '-o $confirm = = ' Y ']; then
/BIN/RM-RF ~/.trash/
/BIN/RM-RF ~/.trash/. 2>/dev/null
Fi
}
- 在命令行下面刷新一下环境配置,即可生效:
[Email protected] ~]# source ~/.BASHRC
- source命令的作用就是用来执行一个脚本,那么:source a.sh 同直接执行 ./a.sh 有什么不同呢,比如你在一个脚本里export $KKK=111 ,如果你用./a.sh执行该脚本,执行完毕后,你运行 echo $KKK ,发现没有值,如果你用source来执行 ,然后再echo ,就会发现KKK=111。因为调用./a.sh来执行shell是在一个子shell里运行的,所以执行后,结构并没有反应到父shell里,但是source不同它就是在本shell中执行的,所以可以看到结果
Disable RM command, use MV command to set up Recycle Bin for Linux