The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #3 (permalink)  
Old 11-22-2007
uvrakesh uvrakesh is offline
Registered User
  
 

Join Date: Dec 2005
Posts: 78
atomated ftp script, modify as per your request

#! /bin/sh
#Do an ftp and get the list of filenames starting with ULT
ftp -ivn hostname <<INPUT >& out
user rakesh Welcome
ls ULT*
bye
INPUT

#Obtain the latest filename inside the variable filename using sort command
filename=`awk '{if($NF ~ "ULT") {print $NF}}' out | sort -r | sed -ne '1p'`


#Do ftp again and get the desired file
ftp -ivn hostname <<INPUT >& out
user rakesh Welcome
get $filename