am downloading daily FTP File through the following command:
wget -mN --ftp-user=myuser --ftp-password=mypassword ftp://ftp2.link.com/ -P /home/usr/public_html/folder/folder2
my file structure are like this:
can you please let me know how can extract only the latest downloaded file only
usually am using the following command to unzip the file, but i don't know what should i add to extract only the latest file
unzip -o /home/user/public_html/folder/folder2/ftp2.directory/????.zip -d /home/user/public_html/folder/folder2/
you help is really approciated
Thanks in Advance
Updated Answer
I thought your question was about FTP, but it is maybe about finding the newest file to unzip.
You can get the newest file like this:
newest=$(ls -t /home/user/public_html/folder/folder2/ftp2.directory/*zip | head -1)
and see the value like this:
echo $newest
and use it like this:
unzip -o "$newest" ...
Original Answer
You can probably string something together using lftp
. For example, I can get a listing in reverse time order with the newest file at the bottom like this:
lftp -e 'cd path/to/daily/file; ls -lrt; bye' -u user,password host | tail -1