Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linux Rename file with only time/date stamp

I have a single file which I want to rename mv to year_month_day_h:m:s - whats the best way to do that?

I've tried the following but it doesn't dynamically add the correct stamp (original file actually has a backslash in the name):

mv getnw/myfilename.txt "%Y%m%d%H%M%S".txt mv getnw/myfilename.txt "%Y-%m%d%H%M%S".txt mv getnw/myfilename.txt %Y-%m%d%H%M%S.txt mv getnw/myfilename.txt "'date +%Y%m%d%H%M%S'.txt"

like image 578
Tony Avatar asked May 17 '12 15:05

Tony


1 Answers

mv myfile.txt `date +%Y_%m_%d_%H:%M:%S`.txt
like image 73
dsomnus Avatar answered Sep 28 '22 10:09

dsomnus