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

Ralf Mardorf ralf.mardorf at rocketmail.com
Mon Jul 20 22:50:32 UTC 2015


On Mon, 20 Jul 2015 17:11:29 -0400, JMZ wrote:
>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/*
                     ^ the "$" is missing

I usually add $(date "+%Y%m%d_%H%M%S") to the file name. However, to
get an unique number you also could use something like mcookie,
perhaps formatted with printf, e.g. $(printf "%.8b" $(mcookie)) .

$ touch filename_$(date "+%Y%m%d_%H%M%S")-$(printf "%.8b" $(mcookie)).bak.tar.gz
$ ls
filename_20150721_004730-1819074c.bak.tar.gz




More information about the xubuntu-users mailing list