H2 create filenames with date in them

James Bond

Registered
I want to automate my backus using tar and cron but I want to archive to disk for later writing to CD.

How can I create a filename that contains the date in some recognisable form in the tar command? I want to do something like:

tar cvf /tmp/full-ddmmyy.backup /users
^^^^^^

 
How about,

tar cvf /tmp/full-`date '+%d%m%y'`.backup /users

date has a number of formats in which it can output the current date, this one being the one you're looking for; see 'man date' and 'man strftime' for details.
 
I had read the man for date and I knew that I wanted to use something like the example but what I did not know was the trick with the '`' character.

Is there documentation somewhere that describes things like this?
 
The command in `` is executed prior to the rest of the line being evaluated...it should be documented in the shell manpages (for one), buried in the substitution sections. Also should be a little more prevalent in a beginning Unix book, I would think.
 
Back
Top