Date: Sat, 06 Jun 1998 08:16:12 -0500 From: Slyce <slyce@onramp.net> To: FreeBSD Questions <questions@FreeBSD.ORG> Subject: BASH script help... Message-ID: <3579411C.25FB6F54@onramp.net>
next in thread | raw e-mail | index | archive | help
I'm creating a script to backup some files under dos in a tarball.... I want to be able to save the last five backups.... I'm saving them in dos_backup_060198_073456_1.tar.gz format.... How can I strip the tar.gz and increment the 1 to 2.... For instance, I have dos_backup_060198_073456_1.tar.gz and dos_backup_060298_073456_2.tar.gz and just created a new backup file, but need to rename the previous two by incrementing the last number by one, so the old dos_backup_060198_073456_1.tar.gz becomes dos_backup_060198_073456_2.tar.gz, the old dos_backup_060298_073456_3.tar.gz becomes dos_backup_060298_073456_3.tar.gz and the new one is dos_backup_060398_073456_1.tar.gz.... Here's the script so far.... #! /bin/sh date=$(date "+%m%d%y_%H%M%S") echo "Backing-up Windows95 files..." echo "Checking for old backups..." if [ -f /usr/local/backup/dos_backup_*_5.tar.gz ]; then echo "Deleting old backup..." rm /usr/local/backup/dos_backup_*_5.tar.gz fi for i in /usr/local/backup/dos_backup_*.tar.gz; do ******THIS IS WHERE I WANT TO RENAME THE OLD FILES********* done echo "Creating new backup file" tar czf /usr/local/backup/dos_backup_${date}_1.tar.gz /usr/msdos/windows/applic~1 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3579411C.25FB6F54>