Remove parts from a filename

I want to remove the beginning and end of a filename and keep the middle.

E.g. tempblast7114_1#21110932.out_ the current filename

I want it to be called 7114_1#21 only

How would I do this??

What's the logic for getting the required output?

Anyway, this will work for your input

echo "tempblast7114_1#21110932.out_"|cut -c 10-18

I need to quickly see the filename, 7114_1#21, the surrounding just messes it up.

Can I use wildcard here? Since I have 84 of these files I want to do the same with.

echo "tempblast*110932.out_"|cut -c 10-18

I also have filenames like 7114_1#1, using the above will leave one digit I want removed....

echo should be removed when I run it or?

Isn't there a way to declare what to be removed, like tempblast and 11093.out_?

I'm totally new at this, appreciate the answer!

see the below code -

#original File name
filename=tempblast12345A11093.out_

#define pattern 1
pat1=tempblast
#define pattern 2
pat2=11093.out_

#find the length of each pattern including filename
WLEN1=${#pat1}
WLEN2=${#pat2}
FLEN=${#filename}

#calculate the first position to cut
POS1=`expr $WLEN1 + 1`
#calculate the second position to cut
POS2=`expr $FLEN - $WLEN2`

#assign the new filename into new variable and print
NFILE=`echo $filename|cut -c$POS1-$POS2`
echo $NFILE