From c0c34ed0b76f3da8ec1324532a40618f618c9359 Mon Sep 17 00:00:00 2001 From: Daniel Dolezal <40464775+daniel156161@users.noreply.github.com> Date: Sat, 22 Aug 2020 01:48:32 +0200 Subject: [PATCH] Update pfsense-backup.sh --- pfsense-backup.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pfsense-backup.sh b/pfsense-backup.sh index 2f8a061..95e720a 100755 --- a/pfsense-backup.sh +++ b/pfsense-backup.sh @@ -66,7 +66,10 @@ if [ $cron -eq 1 ]; then else do_backup if [ ! -z $keepfiles ]; then - ls -d -1tr $destination/*.xml | head -n -$keepfiles | xargs -d '\n' rm -f + remove=$(ls -d -1tr $destination/*.xml | tail -n +$keepfiles | head -n1) + if [ ! -z $remove ]; then + rm -f $(ls -d -1tr $destination/*.xml | tail -n -$keepfiles | head -n1) + fi fi fi else