formatting a string
Michael Schwendt
fedora at wir-sind-cool.org
Mon Feb 28 16:28:10 UTC 2005
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
More information about the redhat-list
mailing list