shell 删除除匹配字符串之外的所有文件夹时间:2023-03-09 02:23:33 file_dir=`find 目录 -mindepth -maxdepth - type d`for dir in $file_dirdo file_name=`basename $dir` if [ $file_name != "目标文件名" ];then rm -rf $dir if [ $? != 0 ];then echo "未删除成功!" exit -2 fi fidone