From 1785d45a8c42f70113bf7867a67879fd8ddb88a8 Mon Sep 17 00:00:00 2001 From: lyq Date: Thu, 7 May 2026 13:43:47 +0800 Subject: [PATCH] sh --- clean_old_logs.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100755 clean_old_logs.sh diff --git a/clean_old_logs.sh b/clean_old_logs.sh new file mode 100755 index 0000000..2672859 --- /dev/null +++ b/clean_old_logs.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +BASE=~/Downloads/sweeper_200/nodes_log +KEEP_DATE=20260501 + +cd "$BASE" || exit 1 + +find . -mindepth 2 -maxdepth 2 -type d \ +| grep -E '/[0-9]{8}$' \ +| awk -F/ -v keep="$KEEP_DATE" '$3 < keep' \ +| while read dir; do + echo "Deleting: $dir" + rm -rf "$dir" +done + +echo "Cleanup complete." \ No newline at end of file