I was reading this answer by @dessert: https://askubuntu.com/a/990771/853133 about how to delete old backup folders from directory using cron in Ubuntu. The command given was:
find /BACKUPDIR/ -mindepth 1 -maxdepth 1 -type d -print0 | sort -z | head -zn-6 | xargs -0 echo rm -rf
However, CentOs 7 doesn't like the z flag in his call to head:
head: invalid option -- 'z'
Is there a work-around for CentOs7?
I took a look at: How can I execute an equivalent of `head -z` when I don't have the `-z` option available? I don't think this explanation is applicable to my question. I don't see how I would change my command if I want to delete backups older than n.
find [...] -delete
. – DopeGhoti Sep 18 '18 at 18:58