#awk -F: -v nu=$num -v trash=$trash '{if (NR<=nu) system("rm -rf "trash"'/'"$2"':'"$3"");
#else print $0}' $mvlog | sort -o $mvlog
awk -F: -v nu=$num -v trash=$trash '{if (NR<=nu) system("rm -rf "trash"'/'"$2"':'"$3"");
else print $0}' $mvlog >> $tmp
mv $tmp $mvlog
}
JUG=
#目录处理函数
function jug_cur()
{
local tmp=
local dirname=$1
local jug=${dirname//*/}
if [ "$jug" == "." ];then
var_pwd=${dirname/./$(pwd)}
JUG=0
elif [ "$jug" == ".." ];then
tm=$(pwd)
tmp=${tm%/*}
var_father=${dirname/../$tmp}
JUG=1
#elif [ "$jug" == "~" ];then
#return 2
else
JUG=2
fi
}
#命令不带参数时的普通文件删除函数
function rm1
{
local filename=$(basename $from1)
local dirname=$(dirname $from1)
jug_cur $dirname
if [ "$JUG" -eq 0 ];then
dirname=$var_pwd
elif [ $JUG -eq 1 ];then
dirname=$var_father
fi
if [ -d "$from1" ];then
echo "rm: cannot remove '$from1': Is a directory"
else
if [ ! -e $from1 ];then
file_null $from1
else
echo "$dirname:$filename:$random:$(date +%Y-%m-%d.%T)" >> $mvlog
mv "$from1" "$trash/$filename:$random"
fi
fi
}
#rm -i
function rmi()
{
local filename=$(basename $from2)
local dirname=$(dirname $from2)
jug_cur $dirname
if [ $JUG -eq 0 ];then
dirname=$var_pwd
elif [ $JUG -eq 1 ];then
dirname=$var_father
fi
if [ -f "$from2" ];then
echo -n "rm: remove regular file '$from2'?"
read answer
if [ "$answer" = 'y' -o "$answer" = 'Y' ];then
echo "$dirname:$filename:$random:$(date +%Y-%m-%d.%T)" >> $mvlog
mv "$from2" "$trash/$filename:$random"
fi
else
if [ ! -e $from2 ];then
file_null $from2
else
echo "rm: cannot remove '$from2': Is a directory"
fi
fi
}
#rm -f
function rmf()
{
local filename=$(basename $from2)
local dirname=$(dirname $from2)
jug_cur $dirname
if [ $JUG -eq 0 ];then
dirname=$var_pwd
elif [ $JUG -eq 1 ];then
dirname=$var_father
fi
if [ -f "$from2" ];then
echo "$dirname:$filename:$random:$(date +%Y-%m-%d.%T)" >> $mvlog
mv "$from2" "$trash/$filename:$random"
else
if [ ! -e $from2 ];then
:
else
echo "rm: cannot remove '$from2': Is a directory"










