🌱 Remove old files
ls -r1 $PT_MYSQLBACKUPPATH/ | tail +$(($PT_FILESTOKEEP+1)) | xargs rm
ls -r1
will list all files in reverse order, one file per line.tail +$number
filters the first $number-1 files of the list out (resp. displays all files beginning from $number till the last one).xargs
will executerm
with all file names from standard input.