Unix questions - Re: How to easily append (in shell script) a timestamp to tar

This is Interesting: Free IT Magazines  
Home > Archive > Unix questions > December 2007 > Re: How to easily append (in shell script) a timestamp to tar





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Re: How to easily append (in shell script) a timestamp to tar
Floyd L. Davidson

2007-12-12, 1:26 pm

kmlincoln100@hotmail.com (Matthew Lincoln) wrote:
>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 shell 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?
>
>If not: Is there a (short) work around (in bash) which let me create such a timestamp?
>
>Thank you
>Matthew


tar czvf "/usr/local/user234/bkp-$(date +%F).tar.gz" /home/users/pmiller/

See the man page for /date/ for other options. The man
page for /bash/ will explain "$(command)".

--
Floyd L. Davidson <http://www.apaflo.com/floyd_davidson>
Ukpeagvik (Barrow, Alaska) floyd@apaflo.com
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com