#!/bin/bash
function myls()
{
local y=`ls`
#echo $y
for z in $y;do
if [ -d $z ];then
#echo "进入子目录"
cd `pwd`/$z
if [ "$z" = "$del_dir" ]
then
#echo "你要找的目录是:$z"
echo "你需要删除的目录是:`pwd`"
echo "是否删除目录$com_dir(yes/no)"
read yes_no
if [ "$yes_no" = "yes" ]
then
rm -rf `pwd`
echo "已删除目录 $z"
echo "是否继续查找该目录(yes/no)"
read ok_no
if [ "$ok_no" = "yes" ]
then
echo "继续查找中..."
else
exit
fi
else
echo "该目录 $z 没被删除"
echo "是否继续查找该目录(yes/no)"
read ok_no
if [ "$ok_no" = "yes" ]
then
echo "继续查找中..."
else
exit
fi
fi
fi
myls
#echo "返回上一级目录";
cd ..
fi
done
}
echo "请输入在哪个目录下查找:"
read dir
echo "请输入需查找并删除的目录:"
read del_dir
cd $dir
echo "查找中..."
if [ -d $dir ]
then
myls
else
echo "您输入的目录$dir不存在!"
exit
fi
阅读(1092) | 评论(0) | 转发(0) |