From owner-freebsd-questions Fri Feb 8 3:31:45 2002 Delivered-To: freebsd-questions@freebsd.org Received: from mail.mishkei.org.il (mail.mishkei.org.il [212.116.161.8]) by hub.freebsd.org (Postfix) with ESMTP id 3CA6E37B41E for ; Fri, 8 Feb 2002 03:31:39 -0800 (PST) Received: from dhcp-251 (212.116.170.38.knet.co.il [212.116.170.38]) by mail.mishkei.org.il (8.9.3/8.9.3) with ESMTP id NAA27233; Fri, 8 Feb 2002 13:30:43 +0200 (IST) Subject: Re: using `date` in a script From: Gilad Rom To: Giorgos Keramidas Cc: Brett Jackson , questions@FreeBSD.ORG In-Reply-To: <20020208025959.GA24241@hades.hell.gr> References: <20020207120404.O7616-100000@bsduser.ca> <20020208025959.GA24241@hades.hell.gr> Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Evolution/1.0.1 Date: 08 Feb 2002 11:30:20 +0000 Message-Id: <1013167823.247.7.camel@dhcp-251.meshek.eh> Mime-Version: 1.0 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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