> -----Original Message-----
> From: Robert P. J. Day [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, January 23, 2003 11:20 AM
> To: [EMAIL PROTECTED]
> Subject: Re: how to use current date as file extension?
> 
> 
> On Thu, 23 Jan 2003, Jan wrote:
> 
> > Jianping Zhu wrote:
> > > I have redhat 7.3, i want to use currnt date as file 
> extension by using
> > > following command.
> > > mv myfile myfile.${`date`}
> > > but it does not work.
> > > how to do that? 
> > > Thanks
> > > 
> > Like this:
> > 
> > mv myfile "myfile.$(date)"
> > 
> > - $() with round brackets is the one to use. However, that 
> leaves you 
> > with a filename with embedded spaces!
> 
> more to the point, you should decide exactly what format you want
> that date extension in, and "man date" to see the options through
> which you can generate that format.
> 
> eg  $(date +%d%m%y)
> 
> that sort of thing.
> 
> rday

Probably best to use
$date +%Y%m%d

Which (for today) would give 20030123 and for tomorrow,
20030124, etc., which means that it can be sorted based
on the extension and come out in logical order.

BTW, someone else (also) suggested 
currdate=`date -s +%Y%m%d`
mv myfile myfile.$currdate
which is NOT what you want; the -s will mess it up; probably
just a typo, leave out the -s and that works.

Bill Ward



-- 
redhat-list mailing list
unsubscribe mailto:[EMAIL PROTECTED]?subject=unsubscribe
https://listman.redhat.com/mailman/listinfo/redhat-list

Reply via email to