Kevin Saenz wrote:
Hi all,
I have a bash script where I create a tar.gz file I would grab current date and add it to the file name. Could anyone
please advise where I could look so I can develop my script
further?
As others have pointed out "date" is the command you're looking for, "man date" for details.
I noticed a lot of people suggesting GNU tar command switches (specifically -z to compress on the fly). Be careful if you plan on using your script anywhere that DOESNT have the GNU tar version of tar.
To get around this (on Solaris specifically) I use the following syntax to create compressed tar files:
tar -cvf - list_of_files | gzip - > myfile-$(date +'%format').tar.gz
Some Solaris systems don't have gzip (pre Solaris 8 IIRC) so you'd need to install it manually or use "compress" instead of "gzip".
I know this is a "Linux" mailing list, but I thought I'd throw this in anyway :)
Have Fun,
James
-- SLUG - Sydney Linux User's Group - http://slug.org.au/ More Info: http://lists.slug.org.au/listinfo/slug
