I have the following input file:
a,10,12,13
b,20,22
c,30
d,33
and would like to append zeros until each line has three numbers, so this should be the output:
a,10,12,13
b,20,22,0
c,30,0,0
d,33,0,0
In sed
I could do use these two commands:
sed 's/\([a-z],[0-9]\+$\)/\1,0,0/g'
sed 's/\([a-z],[0-9]\+,[0-9]\+$\)/\1,0/g'
My regex knowledge is limited to sed
and I would like to know how to achieve this with awk
or perl
.