Date: Tue, 20 Aug 2002 10:23:01 -0400 From: mpd <mpd@rochester.rr.com> To: MET <met@uberstats.com> Cc: 'freebsd-questions-en' <freebsd-questions@FreeBSD.ORG> Subject: Re: A simple Shell script Question || Printing the date in a file name Message-ID: <20020820142301.GA20099@rochester.rr.com> In-Reply-To: <001701c24854$4f031510$6901a8c0@SURVIVAL> References: <001701c24854$4f031510$6901a8c0@SURVIVAL>
next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, Aug 20, 2002 at 10:17:23AM -0400, MET wrote: > 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 something like this should work: #!/bin/sh BAK=Gunks-`date "+%m-%d-%Y"`.tar.bz2 tar cjf $BAK Gunks.txt > > ~ Matthew > mike -- ___________________________________________________________ "IT IS A GOOD THING WE ESCAPED FROM THE OZONE LAYER!!!!!!!" - Pokey the Penguin from "POKEY THE HIS FRIENDS" 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?20020820142301.GA20099>