[ubuntu-za] Copy log file with date-time in name

Greg Raubenheimer gregraubie at gmail.com
Thu Mar 11 12:08:32 GMT 2010

On Thu, Mar 11, 2010 at 2:00 PM, Nico Michael(PtaISP)
<nick.michael at ptaisp.co.za> wrote:
> Hi There
> I need to write a simple shell script to copy a file from one folder to
> another and add the dateand time in the targetfile name
> cp /usr/mylogs/mylogfile.log /usr/mylogs/history/mylogfile_2010-03-11.log
> Please advise
> regards
> Nico

Hi Nico

You can use:
cp /usr/mylogs/mylogfile.log /usr/mylogs/history/mylogfile_`date

man date will give you all the formats you can use.


More information about the ubuntu-za mailing list