Rename a file sequencially in UNIX

I need to be able to look for the last file in a dirctory in UNIX,
the file satrt with EFT
so this work

file=$(ls -tr $EFT*.dat | tail -1) # Select the latest file

my last file is EFT1234.dat
then I need to be able to get a file that I just ftp and rename with this
name EFT1234.dat but plus 1

file=$(ls -tr $EFT*.dat | tail -1) # Select the latest file
filesuffix=${file%.dat} # Remove the extension
let numlength=${#filesuffix}-${#EFT} # Detemine the length of the numeric
typeset -R$numlength filenum=$filesuffix # Remove the number from the right
get "$file $numlength $filenum"

I also try

filesuffix=${EFT%.dat} # Remove the extension

I am getting tjhe following:
The 03121000.DSB is the file that I just FTP and I need to rename EFT1235.dat

+ 0<<
quote user banftp_finaid
quote pass gvf1!3Mk
cd orgs
cd "Financial Aid"
cd MIIS
cd 0910
cd FTP
get 03121000.DSB
# The start of a filename
file=+ tail -1
+ tail -1
+ ls -tr 3526_337092.dat EFT1234.dat HISTOGRAM200910.dat Histogram_200910.dat eluppdtop.dat idoc.dat lockbox_payments.dat
+ ls -tr 3526_337092.dat EFT1234.dat HISTOGRAM200910.dat Histogram_200910.dat eluppdtop.dat idoc.dat lockbox_payments.dat
EFT1234.dat # Select the latest file
filesuffix= # Remove the extension
let numlength=0-0 # Detemine the length of the numeric
typeset -R filenum= # Remove the number from the right
get " "

Perhaps a simpler way of getting to the number

echo EFT1235.dat | tr -cd '[:digit:]'
1235

the tr command with the -d deletes characters that match
but the -c says to use complement of what I provide
the [:digit:] is a special class for numbers; there are many others too:o

Not sure your problem, but if you need rename a file, you can try this code:

$ echo "EFT1234.dat" |awk '{a=substr($0,4,4)+1; print "EFT" a ".dat"}'
EFT1235.dat
echo "EFT1234.dat" |perl -lne '/([A-Z]+)([0-9]+).*/; print $1.($2+1).".dat";'

or more shorter:-

echo "EFT1234.dat" | perl -lpe 's/\d+/$& + 1/e;' 

BR

[code]
Excuse my ignorance, but If I execute this command in the command line in UNIX works, but how I put this in a shl script?

I have the following

[code]
file=$(ls -tr $EFT*.dat | tail -1) # Select the latest fil e
file=$(ls -tr $EFT*.dat | tail -1) # Select the latest fil e
file |perl -lne '/([A-Z]+)([0-9]+)
let filenum= print $1.($2+1).".dat"

[code]
EFT1234.dat # Select the latest fil e (this is correct)
but this is not working
file |perl -lne '/([A-Z]+)([0-9]+)
let filenum= print .(+1).".dat"
I want to be able to store EFT1234.dat in a variable (file)
then

[code]
file |perl -lne '/([A-Z]+)([0-9]+)
let filenum= print .(+1).".dat"
and ended with EFT1235.dat

[code]