Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

331
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda