How to add character in specific position of a string?

Hi All,

I would like to use sed to add "-" between the following string:

Value: 20060830

Result: 2006-08-30

Pls advice. Thx a lot

Victor


sed 's_\([0-9][0-9][0-9][0-9]\)\([0-9][0-9]\)\([0-9][0-9]\)_\1-\2-\3_'

thx a lot!!!!

Reborg,

Can you tell me why you need a _ after the s and at the end. Is that not redundant? Please let me know

Thanks

reborg used the _ character to delimit the sed command. he could have used / but it would have made it even harder to read. It's best to use a character the shell won't try to interpret. _ is one of those.

Jim,

Thanks man!!! I thought all these days that I have to use only / but it's nice to know that infact we can use anything like _ . Can u use anything other than _ also? Please let me know.

Thanks anyway