am downloading daily ftp file through following command:
wget -mn --ftp-user=myuser --ftp-password=mypassword ftp://ftp2.link.com/ -p /home/usr/public_html/folder/folder2
my file structure this:
- data_69111232_2016-01-29.zip
- data_69111232_2016-01-28.zip
- data_69111232_2016-01-27.zip
can please let me know how can extract latest downloaded file
usually using following command unzip file, don't know should add extract latest file
unzip -o /home/user/public_html/folder/folder2/ftp2.directory/????.zip -d /home/user/public_html/folder/folder2/
you approciated
thanks in advance
updated answer
i thought question ftp, maybe finding newest file unzip.
you can newest file this:
newest=$(ls -t /home/user/public_html/folder/folder2/ftp2.directory/*zip | head -1)
and see value this:
echo $newest
and use this:
unzip -o "$newest" ...
original answer
you can string using lftp
. example, can listing in reverse time order newest file @ bottom this:
lftp -e 'cd path/to/daily/file; ls -lrt; bye' -u user,password host | tail -1
Comments
Post a Comment