From owner-freebsd-questions Thu Feb 7 19:16:31 2002 Delivered-To: freebsd-questions@freebsd.org Received: from mailsrv.otenet.gr (mailsrv.otenet.gr [195.170.0.5]) by hub.freebsd.org (Postfix) with ESMTP id 0641337B41A for ; Thu, 7 Feb 2002 19:16:26 -0800 (PST) Received: from hades.hell.gr (patr530-a049.otenet.gr [212.205.215.49]) by mailsrv.otenet.gr (8.12.2/8.12.2) with ESMTP id g183GE5t021772; Fri, 8 Feb 2002 05:16:15 +0200 (EET) Received: (from charon@localhost) by hades.hell.gr (8.11.6/8.11.6) id g182xx924398; Fri, 8 Feb 2002 04:59:59 +0200 (EET) (envelope-from keramida@freebsd.org) Date: Fri, 8 Feb 2002 04:59:59 +0200 From: Giorgos Keramidas To: Brett Jackson Cc: questions@freebsd.org Subject: Re: using `date` in a script Message-ID: <20020208025959.GA24241@hades.hell.gr> References: <20020207120404.O7616-100000@bsduser.ca> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20020207120404.O7616-100000@bsduser.ca> User-Agent: Mutt/1.3.25i 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 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