formatting a string
Zhang Lei
zhl at nanjing-fnst.com
Tue Mar 1 01:06:39 UTC 2005
"%F" is same as "%Y-%m-%d"
try it as
[zhangl at L-tech zhangl]$ date -d 20050202 +%F
Regards
Zhang Lei
----- Original Message -----
From: "Steve Buehler" <steve at ibapp.com>
To: <ewilts at ewilts.org>; "General Red Hat Linux discussion list"
<redhat-list at redhat.com>
Sent: Tuesday, March 01, 2005 4:32 AM
Subject: Re: formatting a string
> At 10:23 AM 2/28/2005, Ed Wilts wrote:
>
>>On Mon, Feb 28, 2005 at 09:56:23AM -0600, Steve Buehler wrote:
>> > I am writing a shell script (#!/bin/sh) that will change some file
>> > names
>> > around but am having trouble formatting a string. If I have a string
>> > like
>> > this:
>> > 20050202
>> > How can I change it to:
>> > 2005-02-02
>>
>>[ewilts at scsftp ewilts]$ NEWDATE=`date -d 20050202 +%F`
>>[ewilts at scsftp ewilts]$ echo $NEWDATE
>>2005-02-02
>
> THAT is exactly what I was looking for. I am running RHEL ES 3 and my man
> page doesn't have the "%F" option in it. I searched on google to get
> another set of the man pages and sure enough......it is on their. I am
> running:
> # date --version
> date (coreutils) 4.5.3
>
> Not sure why my man pages say they are the same version, but it isn't
> documented there. A "date --help" shows the option.
> Anyway, thank you VERY MUCH
> Steve
>
> --
> redhat-list mailing list
> unsubscribe mailto:redhat-list-request at redhat.com?subject=unsubscribe
> https://www.redhat.com/mailman/listinfo/redhat-list
More information about the redhat-list
mailing list