From fb7b63169315bc1ff1c742dbdcb94a6a44cfb13c Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 12 May 2022 08:54:48 -0600 Subject: [PATCH] remove need to rev sort --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 082f5a44..e312afff 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -86,7 +86,7 @@ mapfile -t list_backups < <(cli -c 'app kubernetes list_backups' | grep "HeavySc if [[ ${#list_backups[@]} -gt "number_of_backups" ]]; then echo -e "\nDeleting the oldest backup(s) for exceeding limit:" overflow=$(expr ${#list_backups[@]} - $number_of_backups) - mapfile -t list_overflow < <(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -t '_' -Vr -k2,7 | awk -F '|' '{print $2}'| tr -d " \t\r" | tail -n "$overflow" | sort -t '_' -V -k2,7) + mapfile -t list_overflow < <(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -t '_' -V -k2,7 | awk -F '|' '{print $2}'| tr -d " \t\r" | head -n "$overflow") for i in "${list_overflow[@]}" do cli -c 'app kubernetes delete_backup backup_name=''"'"$i"'"' &> /dev/null || echo "Failed to delete $i"