I have input:
foo 24 foobar 5 bar bar foo 125
and I would like to have the conclusion:
foo 024 foobar 005 bar bar foo 125
Therefore, I can use these sed substitutions:
s,\([az ]\+\)\([0-9]\)\([az ]*\),\100\2\3, s,\([az ]\+\)\([0-9][0-9]\)\([az ]*\),\10\2\3,
But can I make one replacement that will do the same? Sort of:
if (one digit) then two leading 0 elif (two digits) then one leading 0
Sincerely.
source share