function readDir(){
for element in `ls $1`
do
dir_or_file=$1"/"$element
if [ -d $dir_or_file ]
then
if [ $element = "build" ]
then
echo "$dir_or_file"
rm -rfv $dir_or_file
else
readDir $dir_or_file
fi
fi
done
}
root_dir=$(cd "$(dirname "$0")";pwd)
readDir $root_dir
用网上常见的代码改了改,不再需要指定路径,直接拖放该文件到你想清除build的目录下运行即可,避免新手不填写路径,或者路径填写错误的问题。