Reputation: 19
Using sed, how can I change an input string like 9872
to 39 38 37 32
i.e. insert digit 3 before and a space after each digit of entered string 9872.
Input string:
9872
Required output:
39 38 37 32
Upvotes: 0
Views: 91
Reputation: 13626
And just for completeness, a more general way using regex references.
echo 9872 | sed -r 's/([[:digit:]])/3\1 /g'
Upvotes: 3