From 8c65af3332dc42c727b1a094afe34d7cc97e1970 Mon Sep 17 00:00:00 2001 From: xyj <10908227994@qq.com> Date: Fri, 8 Dec 2023 14:57:36 +0800 Subject: [PATCH] update --- bash/delete_than.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/bash/delete_than.sh b/bash/delete_than.sh index 1f1f4d4..a5781eb 100644 --- a/bash/delete_than.sh +++ b/bash/delete_than.sh @@ -2,15 +2,16 @@ set -e # 指定文件夹路径 folder="/home/pi/mp4" - +# 进入文件夹 +cd $folder # 获取文件夹的大小 -size=$(du -sh "$folder" | awk '{print int($1/1024/1024)}') +size=$(du -sh "$folder" | awk '{print int($1/1024)}') while [[ $size -gt 20 ]] do # 获取最早创建的文件 - oldest_file=$(ls -tr | head -1 | xargs) + oldest_file=$(ls $folder -tr | head -1 | xargs) rm -f $oldest_file - size=$(du -sh "$folder" | awk '{print int($1/1024/1024)}') + size=$(du -sh "$folder" | awk '{print int($1/1024)}') if [[ $size -le 20 ]] then exit 0