diff --git a/bash/delete_than.sh b/bash/delete_than.sh index a5781eb..c93a0e7 100644 --- a/bash/delete_than.sh +++ b/bash/delete_than.sh @@ -5,14 +5,14 @@ folder="/home/pi/mp4" # 进入文件夹 cd $folder # 获取文件夹的大小 -size=$(du -sh "$folder" | awk '{print int($1/1024)}') -while [[ $size -gt 20 ]] +size=$(du -sh "$folder" | awk '{print int($1)}') +while [[ $size -gt 50 ]] do # 获取最早创建的文件 oldest_file=$(ls $folder -tr | head -1 | xargs) rm -f $oldest_file - size=$(du -sh "$folder" | awk '{print int($1/1024)}') - if [[ $size -le 20 ]] + size=$(du -sh "$folder" | awk '{print int($1)}') + if [[ $size -le 50 ]] then exit 0 fi