Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

334
Views
Get wget to download only new items from a list

I've got a file that contains a list of file paths. I’m downloading them like this with wget:

wget -i cram_download_list.txt

However the list is long and my session gets interrupted. I’d like to look at the directory for which files already exist, and only download the outstanding ones.

I’ve been trying to com up with an option involving comm, but can’t work out how to loop it in with wget.

File contents look like this:

ftp://ftp.sra.ebi.ac.uk/vol1/run/ERR323/ERR3239280/NA07037.final.cram
ftp://ftp.sra.ebi.ac.uk/vol1/run/ERR323/ERR3239286/NA11829.final.cram
ftp://ftp.sra.ebi.ac.uk/vol1/run/ERR323/ERR3239293/NA11918.final.cram
ftp://ftp.sra.ebi.ac.uk/vol1/run/ERR323/ERR3239298/NA11994.final.cram

I’m currently trying to do something like this:

ls *.cram | sed 's/^/ftp:\/\/ftp.sra.ebi.ac.uk\/vol1\/run\/ERR323\/ERR3239480\//' > downloaded.txt
comm -3 <(sort cram_download_list.txt) <(sort downloaded.txt) | tr -d " \t" > to_download.txt
wget -i to_download_final.txt
over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

wget -c -i <(find -type f -name '*.cram' -printf '%f$\n' |\
             grep -vf - cram_download_list.txt )

Finds files ending in cram and prints them followed by a $ and a newline. This is used as for an inverted regex match list for your download list, i.e. removes any lines ending in the existing file names from your download list.

Added: -c for finalizing incomplete files (i.e. resume download)

Note: does not handle spaces or newlines in file names well, but these are ftp-URLs so that should not be a problem in the first place.

over 4 years ago · Santiago Trujillo Report

0

If you also want to handle partial transferred files, you always need to pass in the complete set of filenames that wget is able to check the length. Which means that for this scenario the only way is:

wget -c -i cram_download_list.txt

The files which are already completed will only be checked and skipped.

over 4 years ago · Santiago Trujillo Report

0

I’d like to look at the directory for which files already exist, and only download the outstanding ones.

To get such behavior you might use -nc (alias --no-clobber) flag. It does skip downloads that would download to existing files (overwriting them). So in your case

wget -nc -i cram_download_list.txt

Beware that this solution does not handle partially downloaded files.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!