How to use substr to return data into a shell script variable?

I'm writing a shell script in which I need to be able to pull a portion of the file name out. I'm testing with the following code:

x="O1164885.DAT"
y=`ls -ltr *${x}|awk '{print substr($0,3)}'`
echo ${x}|awk '{print substr($0,3)}'
echo "y="$y

I can echo it to the screen just fine but I can't figure out how to store it back into a script variable.

Any help would be appreciated.

Thanks!

which line are you truing to put in a var?

Im guessing thats what you wanted:
somevar=`echo ${x}|awk '{print substr($0,3)}'`

That works great! Many thanks!

Another method using no pipes:

somevar=`expr substr "$x" 1 3`