From owner-freebsd-questions Tue Aug 20 8:32: 6 2002 Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 96EEF37B400 for ; Tue, 20 Aug 2002 08:32:03 -0700 (PDT) Received: from magnesium.net (toxic.magnesium.net [207.154.84.15]) by mx1.FreeBSD.org (Postfix) with SMTP id 2045D43E65 for ; Tue, 20 Aug 2002 08:32:03 -0700 (PDT) (envelope-from negative@magnesium.net) Received: (qmail 47802 invoked by uid 1224); 20 Aug 2002 15:32:02 -0000 Date: 20 Aug 2002 08:32:02 -0700 Date: Tue, 20 Aug 2002 08:32:02 -0700 From: Jim Geovedi To: Barry Byrne Cc: MET , 'freebsd-questions-en' Subject: Re: A simple Shell script Question || Printing the date in a file name Message-ID: <20020820153202.GB43729@toxic.magnesium.net> References: <001701c24854$4f031510$6901a8c0@SURVIVAL> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4i Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG > #!/bin/sh > DATE = `date +%Y-%m-%d`; > ARCHIVED="Gunks-$DATE.tar.bz2"; > tar cjf $ARCHIVED Gunks.txt > > > I have a simple shell script that archives and compresses the output of > > a PHP script and then moves it to another location. However, every time > > it runs it replaces the backup that was previously there. So naturally > > to keep this from happening the file names have to be different. So I > > wanted to print the date in a file name. For example > > > > filename-8-20-2002.tar.bz2 > > > > So how might I do that? > > > > I'm archiving/compressing like this - and that's when I'd like the date > > to be appended to the name. > > > > tar cjf Gunks-{insert date}.tar.bz2 Gunks.txt let's make it online. :-) tar cjf Gunks-`date "+%F"`.tar.bz2 Gunks.txt -- Jim Geovedi, negative@{,toxic.}magnesium.net http://www.magnesium.net/~negative/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message