Remove leading string in bash
The commands you passed to sed
mean: if a line matches the regex, delete it. That's not what you want.
echo "$TEST" | sed 's/rev0*//'
This means: on each line, remove rev followed by any number of zeroes.
Also, you don't need sed
for such a simple thing. Just use bash and its parameter expansion:
shopt -s extglob # Turn on extended globbing.
echo "${TEST##rev*(0)}" # Remove everything from the beginning up to `rev`
# followed by the maximal number of zeroes.
POSIXly:
test='rev00000010'
number=${test#"${test%%[1-9]*}"}
Would remove every thing to the left of the left-most non-zero digit.
Bournely/universally:
number=`expr "x$test" : 'xrev0*\(.*\)'`
If you already have the variable TEST just print it with all letter removed
printf "%.0f\n" ${TEST//[a-z]/}
or
printf "%g\n" ${TEST//[a-z]/}
Do not use %d
or echo
-command becouse numbers with leading 0
is understood as octal