I have a folder contains one or more tar.gz files. I want to add current date before each files when the script run.
Two file name(those files will be created each day, but the name will remain the same):
In first day(2011-10-07), those two files will be renamed to:
In next day(2011-10-08), they are changed to:
Finally, the folder contains the following files:
2011-10-07_file1.tar.gz 2011-10-07_file2.tar.gz 2011-10-08_file1.tar.gz 2011-10-08_file2.tar.gz
How to achieve this using one line? I tried to use "rename" command, but I can only add the date after the file, not before.
cdate=`date +"%Y-%m-%d"`; rename .gz .gz.$cdate *.gz