Re: formatting a string

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

 



On Mon, 28 Feb 2005 09:56:23 -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

$ echo "20050202" | sed -r 's!([0-9]{4})([0-9]{2})([0-9]{2})!\1-\2-\3!'
2005-02-02

-- 
Fedora Core release Rawhide (Rawhide) - Linux 2.6.10-1.1155_FC4
loadavg: 0.40 0.15 0.08

-- 
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