Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

rename a file to todays date.

Status
Not open for further replies.

SM777

Technical User
Mar 7, 2001
208
GB
How do I rename a file to be something like todays date using linux scripting.

e.g. data.zip

to be data_11-06-01.zip
or data_11-Jun-01.zip

Cheers
 
data_`date +%m%d%Y`.zip will give you data_061101.zip. Try playing around with it...
 
Look at the man pages for "date" to see the myriad ways of expressing the date. You can use this command in a script like this. Say you want to run something and save the output to a file with today's date as the extention you could do this:

cat foo > foobar.`date +%j` those are backticks not single quotes, and there is a space between date and the +%j

This would put the output of your command in a file called
foobar.162 d3funct
zimmer.jon@cfwy.com
The software required `Windows 95 or better', so I installed Linux.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top