Académique Documents
Professionnel Documents
Culture Documents
Wget is the non-interactive network downloader which is used to download files from
the server even when the useer has not logged on o the system and it can work in
background without hindering the current process.
GNU wget is a free utility for non-interactive download of files from the Web.
It supports HTTP, HTTPS, and FTP protocols, as well as retrieval through HTTP
proxies.
wget is non-interactive, meaning that it can work in the background, while the
user is not logged on. This allows you to start a retrieval and disconnect from the
system, letting wget finish the work. By contrast, most of the Web browsers require
constant user�s presence, which can be a great hindrance when transferring a lot of
data.
wget can follow links in HTML and XHTML pages and create local versions of
remote web sites, fully recreating the directory structure of the original site.
This is sometimes referred to as recursive downloading. While doing that, wget
respects the Robot Exclusion Standard (/robots.txt). wget can be instructed to
convert the links in downloaded HTML files to the local files for offline viewing.
wget has been designed for robustness over slow or unstable network
connections; if a download fails due to a network problem, it will keep retrying
until the whole file has been retrieved. If the server supports resuming, it will
instruct the server to continue the download from where it left off.
Syntax :
Example :
1. To simply download a webpage:
wget http://example.com/sample.php
wget -b http://www.example.com/samplepage.php
wget -c http://example.com/samplefile.tar.gz
Options :
Syntax
$wget -v
2. -h / �help : This is used to print a help message displaying all the possible
options of the line command that is available with the wget command line options
Syntax
$wget -h [URL]
3. -o logfile : This option is used to direct all the messages generated by the
system to the logfile specified by the option and when the process is completed all
the messages thus generated are available in the log file. If no log file has been
specified then the output messages are redirected to the default log file i.e. wget
-log
Syntax
Syntax
$wget -b [URL]
5. -a : This option is used to append the output messages to the current output log
file without overwriting the file as in -o option the output log file is
overwritten but by using this option the log of the previous command is saved and
the current log is written after that of the previous ones.
Syntax
Syntax
$wget -i inputfile
$wget -i inputfile [URL]
Syntax
Syntax
$wget -c [URL]
9. -w : This option is used to set the system to wait the specified number of
seconds between the retrievals. Use of this option is recommended, as it lightens
the server load by making the requests less frequent. Instead of in seconds, the
time can be specified in minutes using the m suffix, in hours using h suffix, or in
days using d suffix. Specifying a large value for this option is useful if the
network or the destination host is down, so that wget can wait long enough to
reasonably expect the network error to be fixed before the retry.
Syntax
10. -r : this option is used to turn on the recursive retrieving of the link
specified in case of fatal errors also. This option is a recursive call to the
given link in the command line.
Syntax
$wget -r [URL]
This article is contributed by Mohak Agrawal. If you like GeeksforGeeks and would
like to contribute, you can also write an article using
contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org.
See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more
information about the topic discussed above.