Changing a variable Question

I have a variable:

$FILENAME = /XXXX/XXXX/XXXX/file.dat

I want to set another variable that will give me this:

$FILENAME2=filea.dat

So basically i'm chopping up variable $FILENAME.

Not sure cut will do this as i'm looking at different directories so the characther length may be different e.g.

$FILENAME = /server1/test/data/file.dat
or
$FILENAME = /server17/dept_area/test/data/file.dat

What are the best way's to do this?

man basename

basename $FILENAME
file.dat

Learn more about it with

man basename

and

man dirname

, plus learn to use ksh built-ins such as:

#  Make a name for yourself... 
   typeset -l my_name=${0##*/} 
   typeset    my_path=${0%/*}