Remove any text but numbers:

$ echo "123test456.ext" | sed -e s/[^0-9]//g
123456

To get all digits grouped:

$ echo "123test456.ext" | egrep -o [0-9]+
123
456

Remove zeros from the string begining:

old="0004937"
# sed removes leading zeroes from stdin
new=$(echo $old | sed 's/^0*//')

Pad a variable value with zeros

for i in $(seq -f "%05g" 10 15)
do
echo $i
done

will produce the following output:

00010
00011
00012
00013
00014
00015

More generally, bash has printf as a built-in so you can pad output with zeroes as follows:

$ i=99
$ printf "%05d\n" $i
00099

You can use the -v flag to store the output in another variable:

$ i=99
$ printf -v j "%05d" $i
$ echo $j
00099

Notice that printf supports a slightly different format to seq so you need to se %05d instead of %05g.

There is more than one way to increment a variable in bash. You can use for example arithmetic expansion:

var=$((var+1))
((var=var+1))
((var+=1))
((var++))

Or you can use let:

let “var=var+1”
let “var+=1”
let “var++”

Arithmetic in bash uses $((...)) syntax:

var=$((var + 1))


References

SED Manual

How to zero pad a sequence of integers in bash so that all have the same width?

http://tldp.org/LDP/abs/html/dblparens.html

https://askubuntu.com/questions/385528/how-to-increment-a-variable-in-bash

Cheetsheet: sed