Hello i'm using putty and trying to rename a file name with current time stamp ... I've used following Command to rename the files and according to date mv abc.log $(date +%F)prod.txt
above command renames but not able to rename with time, It giving Output as : 2014-05-12prodabc.log
And following command abc.log $(date +%y)$(date +%m)$(date +%d)abcprod.log
giving output as : 140512abc.log
Actually my requirement is as following .
rename abc.log to abc-current timestamp.log
e.g abc.log become abc-12-05-2014-17:31.log
then create new file abc.log
Please Help, Thanking you all in advance..
This this:
You can use
If you want to know how you can control your output have a look at the date Manpages..
If you are using cPanel to create a cron job: be careful that you need back slash for %. this works : cp log.txt log.
date +"\%d\%m\%Y"
.txtUse this:
Here,
+%F-%H:%M
will give you a format like2014-05-19-14:47
. If the renaming has done successfully,touch
will create a new empty file.