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 " "