删除当前所在目录下的所有文件夹的脚本

#这是一个只删除当前所在目录下的所有文件夹的脚本,其他类型的文件不删除。有时候我们解压过多的压缩包,手工删掉目录很费力气,这个脚本可以帮助你。

#!/bin/bash
#This is free software,you can use it erverywhere.
#author:Yan Xiaofeng
#Email: xiaofeng_yan2004@126.com
#function: remove all directory in current directory

red='/E[31;40m'
green='/E[32;40m'
DIRECTORY_LIST=`ls`
j=0
CURRENT=`pwd`

echo -e "$CURRENT"
cd $CURRENT
echo -e "$green /bDo you want to remove all directory in current directory!"
read INPUT
if [ "$INPUT" == "y" ]; then
for i in $DIRECTORY_LIST
do
if [ -d "$i" ]; then
        /bin/rm -rf $i
        echo -e "$green /bRemoved file /"$i/""
        let "j += 1"
        tput sgr0
fi
done

if [ $j == 0 ];then
        echo -e "$red /bMy sir,there is no directory here!"
        tput sgr0
fi
else
        echo -e "$green /bexit $CURRENT"
fi

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值