Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I download the latest file available in ftp server using wget. If I am using the below command it is giving all the files.

wget ftp://id%3Apassword@ftpserver/dir/*

Regards, Ram.

share|improve this question

migrated from Oct 21 '09 at 11:10

This question came from our site for system and network administrators.

why don't you give us a little bit less information to work with? – hop Oct 20 '09 at 16:25

The answer is that you probably can't do this using just wget or any other single tool that I am aware of.

What you probably need to do is write a script that will use wget/curl/whatever that will request a directory listing from the ftp server. Then the script will select and retrieve the right file based on the file's name, or some other criteria.

share|improve this answer
using wget I am able to get all files issue is if I have that file already then it is coming and storeing as file_name.1 I want to download the files which are not available there. – Ram Oct 20 '09 at 23:19

Just add the "-N" option to wget to ignore files older than what you have locally. You could also add the "-nc" to completely skip a file if it already exists, even if the one on FTP is newer.

wget -N ftp://id%3Apassword@ftpserver/dir/*

share|improve this answer

Try to specify the file you want to download. Using '*' will download every file in the directory 'dir'.



...will download exactly the file 'welcome.msg' from the mentioned server.

Check the Wget-Manual.

Update: I'm not sure if I get your problem. Are you trying to sync the content of the remote server (machine running the FTP daemon) with your local server? Are you looking for something like rsync functionality over FTP? If yes, you could try ftpsync (wget alone won't help in this case).

share|improve this answer
Hi The file is like file-name_YYYYMMDD.sql.gz where YYYY - year, MM - month, DD -date I cant specify the exact file name – Ram Oct 20 '09 at 17:18
Seems like a database backup / schema script – Sathya Oct 21 '09 at 12:10

My Solution is this:

curl ''$(curl '' 2>/dev/null | tail -1 | awk '{print $(NF)}')
share|improve this answer
I needed also the latest items*.csv file however curl will not allow wildcart patterns so I solved with a grep command piped after curl. Thanks for sharing your solution as I like it! – Bob Siefkes Apr 19 at 13:02

You must log in to answer this question.