I have tried
echo "ABCDE-123456" | sed 's/-//' | sed 's/./& -/g' A -B -C -D -E -1 -2 -3 -4 -5 -6 -
sed is not putting the - on the first character. How can I make it output
-A -B -C -D -E -1 -2 -3 -4 -5 -6
You can turn around your
sed replacement string to be
Also, no need to call
sed twice as you can combine multiple commands with
sed 's/-//; s/./-& /g'
Note, that you will have a space at the end which you might need to get rid of.