Getting substring from parameter

I would like to get a substring of a string in command line, for example I would like to turn the string

123456789_bla.txt

to

bla

It would be also great to find the postition of a certain characer in a "_" string:

123456789_bla.txt

to

10

I hope someone can understand my problem...

The first question has been answered before, see this thread.

For the second question, the expr index command will do as you want.

$ my_var=123456789_bla.txt
$ expr index $my_var "_"
10

Cheers
ZB

Dear zazzybob!

Thank you for your quick help.