Date: Fri, 8 Feb 2002 04:59:59 +0200 From: Giorgos Keramidas <keramida@ceid.upatras.gr> To: Brett Jackson <brett@bsduser.ca> Cc: questions@freebsd.org Subject: Re: using `date` in a script Message-ID: <20020208025959.GA24241@hades.hell.gr> In-Reply-To: <20020207120404.O7616-100000@bsduser.ca> References: <20020207120404.O7616-100000@bsduser.ca>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020208025959.GA24241>