Getting the name of a file from a directory

Hello, I am very new to scripting so you'll have to bear with me. Basically what I'm trying to do is take a directory and get the filename of the most recent file that starts with some prefix. So I have a directory with:
file_1495907432.bin
file_4324324342.bin
file_3424394322.bin
file_9099432443.bin
file_4787234109.bin
names.doc
names.pdf

from that list i would like to get the most recent file beginning with "file" and store the filename in a variable (var1).
so when i type
echo $var1
it gives the filename of the most recent file.
Any help would be awesome! I have searched a lot of pages and can't find anything.
Thanks in advance!

I guess this script will help you.here pattern is the prefix you want to use

#usage sh scriptname.sh pattern

pattern=$1
var1=`ls -1t $pattern* |sed '1q'`
echo "$var1"

Another option without sed would be:-
pattern=$1
var1=`ls -1t $pattern* |head -1`
echo "$var1"

Regards,
Rony