Skip site navigation (1)Skip section navigation (2)
Date:      08 Feb 2002 11:30:20 +0000
From:      Gilad Rom <rom_glsa@ein-hashofet.co.il>
To:        Giorgos Keramidas <keramida@ceid.upatras.gr>
Cc:        Brett Jackson <brett@bsduser.ca>, questions@FreeBSD.ORG
Subject:   Re: using `date` in a script
Message-ID:  <1013167823.247.7.camel@dhcp-251.meshek.eh>
In-Reply-To: <20020208025959.GA24241@hades.hell.gr>
References:  <20020207120404.O7616-100000@bsduser.ca>  <20020208025959.GA24241@hades.hell.gr>

next in thread | previous in thread | raw e-mail | index | archive | help
Hi,

Use something like this:

bday=`date '+%m/%d/%Y'`
echo $bday

Gilad

On Fri, 2002-02-08 at 02:59, Giorgos Keramidas wrote:
> On 2002-02-07 12:07, Brett Jackson wrote:
> > Hi,
> > 
> > I am having difficulty passing a variable to date(8) and have it spit out
> > the data in the date format.
> > 
> > for example:
> > birthday=19450104
> > 
> > >date -f ccyymmdd $birthday
> > 
> > that is some ugly psuedocode, eh?  Can I even do this?
> > I have read the manpage to see how to format the current date, but am lost
> > somewhere when trying the above.
> 
> Try the following:
> 
> 	$ date -j -f '%Y%m%d' 19450104 '+%c'
> 	Thu Jan  4 04:51:50 1945
> 
> Note the use of options:
> 	-j (do not set date, but only print it).
> 	-f 'input-format' input-date
> 	and '+%c' to define output format.
> 
> -- 
> Giorgos Keramidas . . . . . . . . . keramida@{ceid.upatras.gr,freebsd.org}
> FreeBSD Documentation Project . . . http://www.freebsd.org/docproj/
> FreeBSD: The power to serve . . . . http://www.freebsd.org/
> 
> To Unsubscribe: send mail to majordomo@FreeBSD.org
> with "unsubscribe freebsd-questions" in the body of the message
> 



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1013167823.247.7.camel>