From owner-freebsd-questions Sat Jun 6 11:12:08 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id LAA01936 for freebsd-questions-outgoing; Sat, 6 Jun 1998 11:12:08 -0700 (PDT) (envelope-from owner-freebsd-questions@FreeBSD.ORG) Received: from mailhost.onramp.net (mailhost.onramp.net [199.1.11.3]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id LAA01800 for ; Sat, 6 Jun 1998 11:11:57 -0700 (PDT) (envelope-from slyce@onramp.net) Received: from onramp.net (ppp15-42.dllstx.onramp.net [206.50.201.106]) by mailhost.onramp.net (8.8.7/8.8.7) with ESMTP id NAA17928 for ; Sat, 6 Jun 1998 13:11:51 -0500 (CDT) Message-ID: <3579411C.25FB6F54@onramp.net> Date: Sat, 06 Jun 1998 08:16:12 -0500 From: Slyce X-Mailer: Mozilla 4.04 [en] (X11; I; FreeBSD 2.2.6-RELEASE i386) MIME-Version: 1.0 To: FreeBSD Questions Subject: BASH script help... Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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