CLI Remove Old Backup File Max 5 Older
We have provided a set of command-line instructions for managing backup files. These commands are designed to remove older backup files based on certain criteria. Let me break down each of the commands for you:
-
Removing Old Backup Files Using
ls
,tail
, andxargs
:1
ls -t1 | tail -n +11 | xargs -d '\n' rm
This command is used to list files in a directory by their modification time in descending order (
-t1
). Then, it usestail
to exclude the top 10 files (keeping the 11th and onwards), and finally, it usesxargs
to remove these older files.