I need to get a file from a remote host in Unix. I am using the ftp
command. The issue is I need the latest file from that location. This is how I am doing it:<
You cannot use shell features, like aliases, piping, variables, etc, in ftp
command script.
The ftp
does not support such advanced features using any syntax.
Though, you can do it two-step (to make use of shell features between the steps).
First get a listing of remote directory to a local file (/tmp/listing.txt
):
ftp -nv <
Find the latest file:
latest_file=`tail -1 /tmp/listing.txt`
And download it:
ftp -nv <