echo "abc 123" | sed 's/[0-9]*/& &/g'
output:
a b c 123 123
Why there are spaces between the "abc" letters?
echo "abc 123" | sed 's/[0-9]*/&&/'
output:
abc 123
Why the regex in the above script does not match anything? I thought [0-9]* should match 123 in any case.
---------- Post updated at 08:25 AM ---------- Previous update was at 08:17 AM ----------
ok, for the second question, I figured it out.
it is because sed tries to match the first character and it finds it does not match the input string and it stops further attempt because there's no "g" at the end of the pattern(no global search is needed).