Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Help with date in shell script

I wrote a brief bash shell script (one line) to archive a tarball of a specific directory tree:

cd /opt/GeneWeb/bases && tar cf - "Behne.gwb" | gzip -f9 > "/opt/GeneWeb/bases/BACKUPS/date +%d-%m-%Y-Behne.gwb.tar.gz"

This creates a tarball named like this: 16-08-2017-Behne.gwb.tar.gz

I use a cron job to execute this code once a day. It works fine, but I now want to test for tarballs which are eight days or older, and automatically delete them. That way I'll have snapshots of only the last seven days. The problem is that I have no idea how to accomplish this. Can anyone help with writing this script? TIA!