🌱 Remove old files

Source
ls -r1 $PT_MYSQLBACKUPPATH/ | tail +$(($PT_FILESTOKEEP+1)) | xargs rm
  1. ls -r1 will list all files in reverse order, one file per line.
  2. tail +$number filters the first $number-1 files of the list out (resp. displays all files beginning from $number till the last one).
  3. xargs will execute rm with all file names from standard input.
Made by Brandon . If you find this project useful you can donate.