Add spaces between Characters

I need to add spaces in between characters in a string variable.

Is there a shortcut? I know you can remove the spaces with sed, but does sed have a way to add them?

Example:
I have: DATA01
I want it to be: D A T A 0 1

What I have done so far is to create a function that will parse thru each character and add a space after, but really would like a one line solution.

Any help would be greatly appreciated.

echo 'DATA01' | sed 's/./ &/g;s/^ //'

your mileage may vary!

Thanks... it works great! :smiley:

But I have to know... what is the sed telling me? I have not worked with one that appears this complicated.

sed 's/./ &/g;s/^ //'

s/./ &/g

'.' - matches ANY single character
' &' - substitutes a matched expression/character with itself [&] prefixed with a single space

s/^ //

^ - begining on the line; remove the leading space from the beginning of a line.

With zsh:

% v="DATA01"                
% print "${${v/// }[2,-1]}" 
D A T A 0 1