Assuming a number, say 234, which we want to right pad to 7 digits with zeros:
1. This sed way had been discussed in example 4 of left padding a string as well. The same explanation holds good here. Only difference being instead of having a '0' before &, it is after &.
$ echo 234 | sed -e :a -e 's/^.\{1,6\}$/&0/;ta' 2340000One thing to note is the number 6(one less than actual, which is 7). This is because once the length of the number reaches 7, sed quits. To understand better, put 7 in place of 6 and check the result.