??????????????????????????????????????????????????rm *.txt?????????????????????-rf?????????????????????????????????????????????????????
??????????????????в??Ь????????????????????????????????????????????????????????£???????????linux??????????????????Win???????????
???????????????????????????????????????????????????????????"del ?????/?????????"????
????1 [root@localhost tools]# tree Trash_1.0/
????2 Trash_1.0/
????3 ?????? install_Trash.sh
????4 ?????? Trash_mkdir.sh
?????????????????????Trash_mkdir.sh??д??crontab?????????????????????????????????????????У????????????????????5????????????????????????????????????????install_Trash.sh??????????????????????????????????????
????Trash_mkdir.sh???????
????[root@localhost Trash_1.0]# cat Trash_mkdir.sh
????#!/bin/bash
????month=`date "+%m"`???????????????????????? #???????·?
????day=`date "+%d"`???????????????????????????? #???????????
????last_day=`date -d "-1 day" "+%d"`????????????#???????·?
????last_day_m=`date -d "-1 day" "+%m"`?????? #??????????
????del_day=`date -d "-5 day" "+%d"`????????????#?????????·?
????del_day_m=`date -d "-5 day" "+%m"`???????? #????????????
????Trash_dir="/tmp/del_bak"????????????????????#?????????
????tmp_dir="/tmp/del_bak/tmp"???????????????? #??????????????
????#??????????????????????777???15 if [ ! -d $Trash_dir ]
????then
????/bin/mkdir -p $Trash_dir
????/bin/chmod 777 $Trash_dir
????fi
????if [ ! -d $tmp_dir ]
????then
????/bin/mkdir -p $tmp_dir
????/bin/chmod 777 $tmp_dir
????fi
????if [ ! -d /tmp/del_bak/$month ]
????then
????/bin/mkdir /tmp/del_bak/$month
????/bin/chmod 777 /tmp/del_bak/$month
????fi
????if [ ! -d /tmp/del_bak/$month/$day ]
????then
????/bin/mkdir /tmp/del_bak/$month/$day
????/bin/chmod 777 /tmp/del_bak/$month/$day
????fi
????Trash_file=`/bin/ls -A $tmp_dir`
????if [ "$Trash_file" != "" ]????????????????????????#????????????賿????????????????????·?????????????£????/tmp/del_bak/tmp???????????????????
????then
????cd $tmp_dir
????if [ ! -d /tmp/del_bak/$last_day_m/$last_day/ ]
????then
????/bin/mkdir -p /tmp/del_bak/$last_day_m/$last_day/
????fi
????/bin/mv $tmp_dir/* /tmp/del_bak/$last_day_m/$last_day/
????fi
????if [ -d $Trash_dir/$del_day_m/$del_day/ ]????????????????#?????????????????
????then
????cd $Trash_dir/$del_day_m/$del_day/ && {
????/bin/rm -rf $Trash_dir/$del_day_m/$del_day/
????}
????fi
????install_Trash.sh????????
????[root@localhost Trash_1.0]# cat install_Trash.sh
????#!/bin/bash
????USER=`/usr/bin/whoami`????????????????????????????????????????????????????#?????????
????TOOLS="/usr/local/tools"???????????????????????????????????????????????? #???Trash_mkdir.sh???????????·???????????????????
????HOME_DIR=`/bin/grep "$USER" /etc/passwd|awk -F ":" '{print $6}'`????#?????????????
????CONF=$HOME_DIR"/.bashrc"????????????????????????????????????????????????????#?????????????????·??
????Trash=`/bin/grep "del" $CONF`????????????????????????????????????????????#?ж?????????????????????
????if [ "$Trash" = "" ]????????????????????????????????????????????????????????#???????????del
????then
????echo "alias del='mv -t /tmp/del_bak/tmp/ --backup=t'" >>$CONF
????fi
????if [ ! -d $TOOLS ]
????then
????/bin/mkdir -p $TOOLS
????fi
????/bin/cp Trash_mkdir.sh $TOOLS????????????????????????????????????????????#????????????????????
????/bin/chmod +x $TOOLS/Trash_mkdir.sh
????if [ -z "`grep 'Trash_mkdir.sh' /var/spool/cron/root`" ]????????????#?ж???????crontab???????????????????
????then
????echo "10 0 * * * $TOOLS/Trash_mkdir.sh" >>/var/spool/cron/root
????fi
????/bin/sh $TOOLS/Trash_mkdir.sh????????????????????????????????????????????#??????????
?????????????
????1?????????????????????
????2????????????????????????????install_Trash.sh?????????????
???????????????CentOS6.5??????????????????????????????????????????????