[NTLUG:Discuss] tar file with date?

Daniel Hauck daniel at yacg.com
Tue Aug 5 11:38:09 CDT 2008


m m さんは書きました:
> I am trying back the while directory with tar.
> I want to have current date append to the backed up file name.
> Google result is 
> 
> tar cvf backup_`date +%d%m%y`.tar
> 
> however, it just don't work on my box.
> I have tried 
> 
> tar cvf backup_${date +%d%m%y}.tar
> 
> this is what I get:
> 
> bash: date_%y%m%d: command not found
> 
> Can any one  help?
> 
> the systems are Fedora 7 and  Fedora 8
> 
> Thanks.

I must say, that's pretty neat!

It worked on my box.  In my case, I did this:

tar cvjf testing_`date +%d%m%y`.tar.bz2 bin

And it backed up my ~/bin folder perfectly.

You said it doesn't work for you.  Can you tell tell me what the result
is?  And perhaps this is a stupid question, but you are aware of the
difference between the use of '[the apostrophe] and ` [the back-tick or
whatever you want to call it] characters?

I also tried your thing with the ${date +%d%m%y} in it and I did not get
the error you got.  Instead, I got "bad substitution" in return.

I am running Fedora 9.  It is not terribly different from Fedora 8 or
even 7.

Are you, by any chance, running a shell other than bash?





More information about the Discuss mailing list