I'd like to make a .tar
file of a particular directory every day of the week. The way I'd like to do it is with a bash script making a tar file every day with crontab.
I was wondering, is there a way to regulate the name of the tar file the the bash script makes? Right now it's the same every time the file is made, becase the bash has just one command:tar -cvf file.tar /home/name/folder/
But I'd like for it to be slightly differnt based on the day e.g. FileTus.tar
, FileWed.tar
, FileFri.tar
,etc..
Is there a way to do this though terminal commands?
Thanks
Best Answer
The
date
command can produce a date as text in whatever format you want. You would then use it in a script something like:This would produce
FileMon.tar
,FileTue.tar
as above. Seeman date
for a description of the different date formats it can produce.