[xubuntu-users] Using the _date_ variable in tar files?

JMZ florentior at gmail.com
Mon Jul 20 21:11:29 UTC 2015


I've tried to set up a shell file to automatically create a compressed 
file of one directory in another directory.  This shell file will later 
be embedded in crontab.  What's difficult is that I can't get the _date_ 
command to stamp a unique record on the tar file.  I thought something 
like this would work:

sudo tar -cjvf /x/y/(date +%a_%b_%F_%T)-b.tar.bz2 /a/b/*

That is, the contents of /a/b/* would be compressed into a file and sent 
to /x/y/.  The tar.bz2 file would be time and date stamped.

I get the following error:

bash: syntax error near unexpected token `('

Which I interpret to mean that _date_ can't be used this way when making 
tar files.

Is there a workaround for this?

Much thanks

More information about the xubuntu-users mailing list