Using current date in file name within script

I need to write a script that will rename a file where the destination file name will obtain and include the system date.  I need help with how to write the line of the script.

Example
mv original.dat new20080201.dat
where 2008 is the year
02 is the month
01 is the day
(i.e.  YYYYMMDD)

Thanks,
Tim Steele
LVL 1
tasteeleAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
sentnerConnect With a Mentor Commented:
Easiest way to rename in one step is to just append the date, as in:

mv original.dat new`date +%Y%m%d`.dat

0
 
tasteeleAuthor Commented:
This isn't working.  It is creating a filename called

newdate+%y%m%d.dat
0
 
tasteeleAuthor Commented:
Nevermind.... Your solution did work. I had an extra space or some, then when I cut and pasted your solution into a file editor I could read more easily I found it.

Thanks for the help and the quick response
0
All Courses

From novice to tech pro — start learning today.