Re: formatting a string

From: Carl Reynolds (redhat-list_at_hyperbole-software.com)
Date: 03/06/05

  • Next message: Karasik, Vitaly: "RE: dns clustering"
    Date: Sun, 06 Mar 2005 01:55:39 -0500
    To: General Red Hat Linux discussion list <redhat-list@redhat.com>
    
    

    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
    >
    > I have about a thousand files so it isn't really feasable for me to be
    > changing the names manually. All of the files are similar to this and
    > I have everything in the script to make the change but this one problem.
    > I have looked into "printf" and "awk/split", but I don't think either
    > one of these would work for me. Maybe one would, but I just couldn't
    > figure it out. Any help would be appreciated.
    >
    > Thanks
    > Steve
    >
    newname=`date -d $filename +"%Y-%m-%d"`

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

  • Next message: Karasik, Vitaly: "RE: dns clustering"

    Relevant Pages

    • formatting a string
      ... I am writing a shell script that will change some file names ... around but am having trouble formatting a string. ...
      (RedHat)
    • Re: formatting a string
      ... > around but am having trouble formatting a string. ... [ewilts@scsftp ewilts]$ echo $NEWDATE ...
      (RedHat)
    • Re: formatting a string
      ... At 10:23 AM 2/28/2005, Ed Wilts wrote: ... >> around but am having trouble formatting a string. ... I am running RHEL ES 3 and my man ...
      (RedHat)
    • Re: formatting a string
      ... > around but am having trouble formatting a string. ... Fedora Core release Rawhide - Linux 2.6.10-1.1155_FC4 ...
      (RedHat)