| 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
|