Cutting file name from end

Dear Friends,

I want to take last 10 characters of a file name in a variable.

E.g.
file name is
123432311234567890.txt
then we want "1234567890" to be taken in an variable.

Request you to guide me to do the same

Thanks in anticipation

Anushree

try

$ a=123432311234567890.txt
$ expr $a : '.*\(..........\).txt'
1234567890
$ 

one way:

#  echo "123432311234567890.txt" | nawk -F. '{print substr($1,length($1)-9,10)}' 
1234567890
# a=123432311234567890.txt
# a=${a%.*};t=${a%??????????};echo "${a#$t}"
1234567890
# echo "123432311234567890.txt" | sed 's/.*\(.\{10\}\)\.txt/\1/'
1234567890
# a=123432311234567890.txt
# typeset -R10 a=${a%.*}
# echo $a
1234567890
 var=$(echo "123432311234567890.txt"  | ruby -e 'puts gets.split(/\./)[0..-2].join(".")[-10..-1]') 

through sed..

STR=$(echo "123432311234567890.txt"|sed 's/.*\(.\{10\}\).txt/\1/')

Or...

STR=$(basename 123432311234567890.txt .txt | tail -c 11)
echo 123432311234567890.txt  |awk '{print substr($0,length-13,10)}'