本文共 1087 字,大约阅读时间需要 3 分钟。
vi rm.sh#! /bin/bash ##linux删除huishou=~/.temp (($#==0)) && { echo "No paraments!";exit 1; } if [ ! -d $huishou ]; then mkdir $huishou fi for i in $* do if test -e $i then cd $(dirname $i) mv -f $(basename $i) $huishou/$(find $(pwd) -maxdepth 1 -name $(basename $i) | tr "/" "=") cd - else echo "$i:No such file or directory!" fi done vi mv.sh#! /bin/bash #linux恢复cd ~/.temp list=$(for i in $*; do ls |grep "\<$i\>"; done) (($#==0)) && { list=$(ls|grep ""); } for j in $list do file=$(echo $j | tr "=" "/") mv $j ${file%/*}/${file##*/} done #添加自动任务自动删除临时回收站之前的文件 避免造成文件过大。cat>renwu.sh<>/var/spool/cron/rootservice crond restartEOF[root@apple home]# chmod 777 rm.sh [root@apple home]# chmod 777 mv.sh[root@apple home]# lsapple mv.sh renwu.sh rm.sh test[root@apple home]# ./rm.sh test//home[root@apple home]# lsapple mv.sh renwu.sh rm.sh[root@apple home]# ls ~/.temp/=home=test[root@apple home]# ./mv.sh test[root@apple home]# lsapple mv.sh renwu.sh rm.sh test
转载地址:http://fgaum.baihongyu.com/