WGET – usage tips

By | November 17, 2007

Examples:

If you need only to download something from an url:

wget http://cristian-radulescu.ro/image.gif

With user (abc) and password (abc123):

wget http://cristian-radulescu.ro/document.pdf --user=abc --password=abc123

Download from an url list (list.txt):

wget -i list.txt

When the connection fails you can continue:

wget -c http://cristian-radulescu.ro/arhiva.zip

The default number of retries is set to 20. Set the number of retries to infinity:

wget -t 0 -c http://cristian-radulescu.ro/archive.zip

Download all files from a directory:

wget -p http://cristian-radulescu.ro/directory/

Download files with specific extensions (.jpg, .gif, .png):

wget -nd -r -l1 -A.jpg -A.gif -A.png http://cristian-radulescu.ro/pictures/

(-nd no directory, -r recursive download, -l1 level 1, no subdirectories).

Shell script example:

If the files are named useng a pattern (like wallpaper_1.jpg, wallpaper_2.jpg, …, wallpaper_284.jpg, wallpaper_285.jpg) you can use a simple shell script:

#!/bin/bash
for ((i = 1; i <= 285; i ++))
  do
    wget -c "http://cristian-radulescu.ro/wallpapers/wallpaper_"$i".jpg"
done

or type in a console:

for ((i = 1; i <= 285; i ++)); do wget -c "http://cristian-radulescu.ro/wallpapers/wallpaper_"$i".jpg"; done

More details:

wget --help

or

man wget

in a console.

Leave a Reply