Common wget usage examples

Wget is one of my favorite tools in Linux/Unix world. Sometimes, you want to download all the rpm, deb, iso, or tgz files and save them into a directory. Sometimes you need to use it to check your web server status. Here are some of my favorite wget usage examples:

$ wget -i filename.txt
Put the URLs in filename.txt and run wget against it to download a list of files automatically.

How to download large files in a bad connection? You can have a try with –continue option:
$ wget -c http://www.minivps.com/really-big-file.iso
The “-c” option tells wget to continue and retry until downloading completed.

$ wget –spider http://www.minivps.com/
This command is very useful to check a web server’s running status. A “200 OK” in the output means your web server is ready for request.

$ wget -r -np -nd http://www.020i.com/files/
This little command is probably the most used variation. It downloads all files in the /files/ directory on 020i.com, without traversing up to parent directories (-np), and without recreating the directory structure on your machine (-nd).

$ wget -r -np -nd –accept=iso http://www.minivps.com/centos-5/i386/
Adding the -–accept argument with a list of file extensions (comma separated) will grab only these files in the right extensions.

Share Button

Leave a comment

Your email address will not be published. Required fields are marked *