Re: How to easily append a timestamp to tar archive name ?
- From: Martin Klar <martin.klar@xxxxxx>
- Date: Sun, 09 Dec 2007 16:34:26 +0100
Matthew Lincoln schrieb:
I would like to create a tar archive with the well known tar command
tar czvf "/usr/local/user234/bkp.tar.gz" /home/users/pmiller/
It works. However I would like to automatically append a timestamp whenever I call this command
in a (perl) script.
The created archive file name should look like
bkp-20071109-1523.tar.gz
Where the format is preferred as YYYYMMDD-HHMM
Does Gnu-tar offer such an automatic timestamp appending?
AFAIK no.
Assuming you are using a bash you could solve it by:
tar czvf "/usr/local/user234/bkp-$(date +%Y%m%d-%H%M).tar.gz" /home/users/pmiller/
It *should* also work when called from a perl script, but I didn't test it.
HTH Martin
.
- Follow-Ups:
- Re: How to easily append a timestamp to tar archive name ?
- From: Ben Morrow
- Re: How to easily append a timestamp to tar archive name ?
- Prev by Date: Re: How to easily append a timestamp to tar archive name ?
- Next by Date: Re: Questions about the operator \(...)
- Previous by thread: Re: How to easily append a timestamp to tar archive name ?
- Next by thread: Re: How to easily append a timestamp to tar archive name ?
- Index(es):
Relevant Pages
|