formatting a string

From: Steve Buehler (steve_at_ibapp.com)
Date: 02/28/05

  • Next message: Ed Wilts: "Re: formatting a string"
    Date: Mon, 28 Feb 2005 09:56:23 -0600
    To: redhat-list@redhat.com
    
    

    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

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

  • Next message: Ed Wilts: "Re: formatting a string"

    Relevant Pages

    • Re: Fetch the newest file containing the string fgractg*.log in the filename and contains the string
      ... On 2005-10-12, kartik wrote: ... > I am trying to develop a shell script that checks whether the newest ... > file modified today that contains the string 'fgractg*.log' in the ... mind. ...
      (comp.unix.shell)
    • Re: bash: how to echo to the prompt without executing
      ... On 2006-12-27, Berk Birand wrote: ... I then found out about this newsgroup, and figured I could try it ... some string to the bash prompt without actually executing it. ... from within a shell script or function, or even in C or Perl. ...
      (comp.unix.shell)
    • need help with simple script
      ... I need a little help with a simple shell script. ... list the files in the current directory that start with the letters qrt. ... Then I need to cat those files and grep for the string "not disinfected". ... that are created in a quarantine directory by an anti-virus product. ...
      (comp.unix.shell)
    • bash: how to echo to the prompt without executing
      ... I then found out about this newsgroup, and figured I could try it ... some string to the bash prompt without actually executing it. ... Once s/he is done, pressing ... from within a shell script or function, or even in C or Perl. ...
      (comp.unix.shell)
    • Re: Writing idiomatically for the cello and other string instruments
      ... writing for string instrument, specifically the cello. ... Also, get with a cello player and talk, ... Most of us sadly dont have a string player easily available- ...
      (rec.music.theory)