Go to the first, previous, next, last section, table of contents.


Invoking

By default, Wget is very simple to invoke. The basic syntax is:

wget [options] URL1 [URL2 ...]

Wget will simply download all the URLs specified on the command line. URL is a Uniform Resource Locator, as defined below.

Be aware that ksh and its descendants (like zsh) kill off the background processes during logout. To prevent this, use nohup, as documented in system manuals.

However, you may wish to change some of the default parameters of Wget. You can do it two ways: permanently, adding the appropriate command to `.wgetrc' (See section Startup File), or specifying it on the command line.

URL Format

URL is an acronym for Uniform Resource Locator. Wget recognizes the URL syntax as per RFC1738. This is the most widely used form (square brackets denote optional parts):

http://host[:port]/path
ftp://host[:port]/path

You can also encode your username and password within a URL:

ftp://user:password@host/path
http://user:password@host/path

Either user or password, or both may be left out. If you leave out either the HTTP username or password, no authentication will be sent. If you leave out the FTP username, `anonymous' will be used. If you leave out the FTP password, your email address will be supplied as a default password.(1)

You can encode unsafe characters in a URL as `%xy', xy being the hexadecimal representation of the character's ASCII value. Some common unsafe characters include `%' (quoted as `%25'), `:' (quoted as `%3A'), and `@' (quoted as `%40'). Refer to RFC1738 for a comprehensive list of unsafe characters.

Two alternative variants of URL specification are also supported, because of historical (hysterical?) reasons and their wide-spreadedness.

FTP-only syntax (supported by NcFTP):

host:/dir/file

HTTP-only syntax (introduced by Netscape):

host[:port]/dir/file

These two alternative forms are deprecated, and may cease being supported in the future.

If you do not understand the difference between these notations, or do not know which one to use, just use the plain ordinary format you use with your favorite browser, like Lynx or Netscape.

Option Syntax

Since Wget uses GNU getopts to process its arguments, every option has a short form and a long form. Long options are more convenient to remember, but take time to type. You may freely mix different option styles, or specify options after the command-line arguments. Thus you may write:

wget -r --tries=10 http://fly.cc.fer.hr/ -o log

The space between the option accepting an argument and the argument may be omitted. Instead `-o log' you can write `-olog'.

You may put several options that do not require arguments together, like:

wget -drc URL

This is a complete equivalent of:

wget -d -r -c URL

Since the options can be specified after the arguments, you may terminate them with `--'. So the following will try to download URL `-x', reporting failure to `log':

wget -o log -- -x

The options that accept comma-separated lists all use the convention that, when presented an empty list, it means to clear it. This can be useful to clear the `.wgetrc' settings. So, if your .wgetrc sets the exclude_directories to `/cgi-bin', the following example will first reset it, and then set it to exclude `/~nobody' and `/~somebody'. You can also clear the lists in `.wgetrc' (See section Wgetrc Syntax).

wget -X " -X /~nobody,/~somebody

Basic Options

The command line arguments, sorted alphabetically.

`-a logfile'
`--append-output=logfile'
Append to logfile---the same as `-o', but appending to the logfile (or creating a new one if the old does not exist) instead of overwriting the old log file.
`-d'
`--debug'
Turn on debug output, meaning various information important to the developers of Wget if it does not work properly. Your system administrator may have chosen to compile Wget without debug support. In that case `-d' will not work. Please note that even if the program is compiled with debug support, it will not print any debug info unless `-d' is turned on explicitly. See section Reporting Bugs for more information on how to send a bug report.
`-h'
`--help'
Print a help screen. You will also get help if you do not supply command-line arguments.
`-i file'
`--input-file=file'
Read URLs from file, in which case no URLs need to be on the command line. If there are URLs both on the command line and in an input file, those on the command lines will be the first ones to be retrieved. The file need not be an HTML document (but no harm if it is)---it is enough if the URLs are just listed sequentially. However, if you specify `--force-html', the document will be regarded as `html'. In that case you may have problems with relative links, which you can solve either by adding <base href="url"> to the documents or by specifying `--base=url' on the command line.
`-l depth'
`--level=depth'
Specify recursion maximum depth level depth (See section Recursive Retrieval). The default maximum depth is 5.
`-nc'
`--no-clobber'
Do not clobber existing files when saving to directory hierarchy within recursive retrieval of several files. This option is extremely useful when you wish to continue where you left off with retrieval of many files. If the files have the `.html' or (yuck) `.htm' suffix, they will be loaded from the local disk, and parsed as if they have been retrieved from the Web.
`-o logfile'
`--output-file=logfile'
Log all messages to logfile, instead of standard output, which is the default. If you do not wish the log output to be verbose, use `-nv' (non-verbose).
`-q'
`--quiet'
This option is the opposite of verbose, making Wget completely quiet.
`-r'
`--recursive'
Turn on recursive retrieving (See section Recursive Retrieval).
`-t num'
`--tries=num'
Set number of retries to num. Specify 0 or `inf' for infinite retrying.
`-V'
`--version'
Display the version of Wget.
`-v'
`--verbose'
Turn on verbose output, with all the available data. The default output is verbose.

Advanced Options

The following table contains the alphabetically sorted list of the advanced command line arguments, for people familiar with basic operating of Wget, wishing to change its default behavior. Not for the faint of heart.

`-A acclist --accept acclist'
`-R rejlist --reject rejlist'
Specify comma-separated lists of file name suffices or patterns to accept or reject (See section Types of Files for more details).
`-c'
`--continue'
Continue retrieval of FTP documents, from where it was left off by another program or a previous instance of Wget. Thus you can write:
wget -c ftp://sunsite.doc.ic.ac.uk/ls-lR.Z
If there is a file name `ls-lR.Z' in the current directory, Wget will assume that it is the first portion of the remote file, and will require the server to continue the retrieval from an offset equal to the length of the local file. Note that you need not specify this option if all you want is Wget to continue retrieving where it left off when the connection is lost--Wget does this by default. You need this option only when you want to continue retrieval of a file already halfway retrieved, saved by another FTP client, or left by Wget being killed. Without `-c', the previous example would just begin to download the remote file to `ls-lR.Z.1'. The `-c' option is also applicable for HTTP servers that support the Range header.
`-D domain-list'
`--domains=domain-list'
Set domains to be accepted and DNS looked-up, where domain-list is a comma-separated list. Note that it does not turn on `-H'. This option speeds things up, even if only one host is spanned (See section Domain Acceptance).
`--delete-after'
This option tells Wget to delete every single file it downloads, after having done so. It is useful for pre-fetching popular pages through PROXY, e.g.:
wget -r -nd --delete-after http://whatever.com/~popular/page/
The `-r' option is to retrieve recursively, and `-nd' not to create directories.
`--dot-style=style'
Set the retrieval style to style. Wget traces the retrieval of each document by printing dots on the screen, each dot representing a fixed amount of retrieved data. Any number of dots may be separated in a cluster, to make counting easier. This option allows you to choose one of the pre-defined styles, determining the number of bytes represented by a dot, the number of dots in a cluster, and the number of dots on the line. With the default style each dot represents 1K, there are ten dots in a cluster and 50 dots in a line. The binary style has a more "computer"-like orientation--8K dots, 16-dots clusters and 64 dots per line (which makes for 512K lines). The mega style is suitable for downloading very large files--each dot represents 64K retrieved, there are eight dots in a cluster, and 48 dots on each line (so each line contains 3M). The micro style is exactly the reverse; it is suitable for downloading small files, with 128-byte dots, 8 dots per cluster, and 48 dots (6K) per line.
`-e command'
`--execute command'
Execute command as if it were a part of `.wgetrc' (See section Startup File). A command thus invoked will be executed after the commands in `.wgetrc', thus taking precedence over them.
`--exclude-domains domain-list'
Exclude the domains given in a comma-separated domain-list from DNS-lookup (See section Domain Acceptance).
`--follow-ftp'
Follow FTP links from HTML documents. Without this option, Wget will ignore all the FTP links.
`-F'
`--force-html'
When input is read from a file, force it to be treated as an HTML file. This enables you to retrieve relative links from existing HTML files on your local disk, by adding <base href="url"> to HTML, or using the `--base' command-line option.
`-g on/off'
`--glob=on/off'
Turn FTP globbing on or off. Globbing means you may use the shell-like special characters (wildcards), like `*', `?', `[' and `]' to retrieve more than one file from the same directory at once, like:
wget ftp://gnjilux.cc.fer.hr/*.msg
By default, globbing will be turned on if the URL contains a globbing character. This option may be used to turn globbing on or off permanently. You may have to quote the URL to protect it from being expanded by your shell. Globbing makes Wget look for a directory listing, which is system-specific. This is why it currently works only with Unix FTP servers (and the ones emulating Unix ls output).
`--ignore-length'
Unfortunately, some HTTP servers (CGI programs, to be more precise) send out bogus Content-Length headers, which makes Wget go wild, as it thinks not all the document was retrieved. You can spot this syndrome if Wget retries getting the same document again and again, each time claiming that the (otherwise normal) connection has closed on the very same byte. With this option, Wget will ignore the Content-Length header--as if it never existed.
`--retr-symlinks'
Retrieve symbolic links on FTP sites as if they were plain files, i.e. don't just create links locally.
`-H'
`--span-hosts'
Enable spanning across hosts when doing recursive retrieving (See section All Hosts).
`--header=additional-header'
Define an additional-header to be passed to the HTTP servers. Headers must contain a `:' preceded by one or more non-blank characters, and must not contain newlines. You may define more than one additional header by specifying `--header' more than once.
wget --header='Accept-Charset: iso-8859-2' \
     --header='Accept-Language: hr'        \
       http://fly.cc.fer.hr/
Specification of an empty string as the header value will clear all previous user-defined headers.
`--http-user=user'
`--http-passwd=password'
Specify the username user and password password on an HTTP server. Wget will encode them using the basic (insecure) WWW authentication scheme. You can also encode the username and password to the URL (See section URL Format). For more data about security issues with Wget, See section Security Considerations.
`-I list'
`--include-directories=list'
Specify a comma-separated list of directories you wish to follow when downloading (See section Directory-Based Limits for more details)
`-k'
`--convert-links'
Convert the non-relative links to relative ones locally. Only the references to the documents actually downloaded will be converted; the rest will be left unchanged. Note that only at the end of the download can Wget know which links have been downloaded. Because of that, much of the work done by `-k' will be performed at the end of the downloads.
`-L'
`--relative'
Follow relative links only. Useful for retrieving a specific home page without any distractions, not even those from the same hosts (See section Relative Links).
`-m'
`--mirror'
Turn on options suitable for mirroring. This option turns on recursion and time-stamping, sets infinite recursion depth and keeps FTP directory listings. It is currently equivalent to `-r -N -l0 -nr'.
`-N'
`--timestamping'
Turn on time-stamping (See section Time-Stamping for details).
`-nd'
Do not create a hierarchy of directories when retrieving recursively. With this option turned on, all files will get saved to the current directory, without clobbering (if a name shows up more than once, the filenames will get extensions `.n').
`-nH'
Disable generation of host-prefixed directories. By default, invoking Wget with `-r http://fly.cc.fer.hr/' will create a structure of directories beginning with `fly.cc.fer.hr/'. This option disables such behavior.
`-nh'
Disable the time-consuming DNS lookup of almost all hosts (See section Host Checking).
`-np'
`--no-parent'
Do not ever ascend to the parent directory when retrieving recursively. This is a useful option, since it guarantees that only the files below a certain hierarchy will be downloaded. See section Directory-Based Limits for more details.
`-nr'
Do not remove the `.listing' files generated by FTP. This is useful when running a mirror to see the remote file list. It can also be used for debugging purposes.
`-nv'
Non-verbose output--turn off verbose without being completely quiet (use `-q' for that), which means that error messages and basic information still get printed.
`-O file'
`--output-document=file'
The documents will not be written to the appropriate files, but all will be appended to a unique file specified by this option. The number of tries will be set to 1 automatically. If the file is `-', the documents will be written to standard output, and `--quiet' will be turned on. This option is useful for making Wget a part of pipelines (See section Advanced Usage). Be careful, however, since setting `--quiet' turns off all the useful diagnostics Wget can otherwise give. This option is usually a bad choice, as it disables a great number of Wget features, e.g. recursive retrieval.
`--passive-ftp'
Use the passive FTP retrieval scheme, in which the client initiates the data connection. This is sometimes required for FTP to work behind firewalls.
`-P prefix'
`--directory-prefix=prefix'
Set directory prefix to prefix. The directory prefix is the directory where all other files and subdirectories will be saved to, i.e. the top of the retrieval tree. The default is `.' (the current directory).
`--proxy-user=user'
`--proxy-passwd=password'
Specify the username user and password password for authentication on a PROXY server. Like with `--http-user' and `--http-passwd', Wget will encode them using the basic authentication scheme.
`-Q quota'
`--quota=quota'
Specify download quota for automatic retrievals. The value can be specified in bytes (default), kilobytes (with `k' suffix), or megabytes (with `m' suffix). Note that quota will never affect downloading a single file. So if you specify `wget -Q10k ftp://wuarchive.wustl.edu/ls-lR.gz', all of the `ls-lR.gz' will be downloaded. The same goes even when several URLs are specified on the command-line. However, quota is respected when retrieving either recursively, or from an input file. Thus you may safely type `wget -Q2m -i sites'---download will be aborted when the quota is exceeded. Setting quota to 0 or to `inf' unlimits the download quota.
`-S'
`--server-response'
Print the headers sent by HTTP servers and responses sent by FTP servers.
`-s'
`--save-headers'
Save the headers sent by the HTTP server to the file, preceding the actual contents, with an empty line as the separator.
`--spider'
When invoked with this option, Wget will behave as a Web spider, which means that it will not download the pages, just check that they are there. You can use it to check your bookmarks, e.g. with:
wget --spider --force-html -i bookmarks.html
This feature needs much more work for Wget to get close to the functionality of real WWW spiders.
`-T seconds'
`--timeout=seconds'
Set the read timeout to seconds seconds. Whenever a network read is issued, the file descriptor is checked for a timeout, which could otherwise leave a pending connection (uninterrupted read). The default timeout is 900 seconds (fifteen minutes). Setting timeout to 0 will disable checking for timeouts. Please do not lower the default timeout value with this option unless you know what you are doing.
`-w seconds'
`--wait=seconds'
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.
`-X list'
`--exclude-directories=list'
Specify a comma-separated list of directories you wish to exclude from download (See section Directory-Based Limits for more details).
`-x'
The opposite of `-nd'---create a hierarchy of directories, even if one would not have been created otherwise. E.g. `wget -x http://fly.cc.fer.hr/robots.txt' will save the downloaded file to `fly.cc.fer.hr/robots.txt'.
`-Y on/off'
`--proxy=on/off'
Turn PROXY support on or off. The proxy is on by default if the appropriate environmental variable is defined.


Go to the first, previous, next, last section, table of contents.