Re: formatting a string

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"%F" is same as "%Y-%m-%d"

try it as

[zhangl@L-tech zhangl]$ date -d 20050202 +%F

Regards
Zhang Lei

----- Original Message ----- From: "Steve Buehler" <steve@xxxxxxxxx>
To: <ewilts@xxxxxxxxxx>; "General Red Hat Linux discussion list" <redhat-list@xxxxxxxxxx>
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@scsftp ewilts]$ NEWDATE=`date -d 20050202 +%F`
[ewilts@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@xxxxxxxxxx?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list

-- redhat-list mailing list unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe https://www.redhat.com/mailman/listinfo/redhat-list

[Index of Archives]     [CentOS]     [Kernel Development]     [PAM]     [Fedora Users]     [Red Hat Development]     [Big List of Linux Books]     [Linux Admin]     [Gimp]     [Asterisk PBX]     [Yosemite News]     [Red Hat Crash Utility]


  Powered by Linux