Detailed explanation of the linux wget command
Wget is a commonly used download tool in the Linux system, capable of downloading files from remote servers using protocols such as HTTP, HTTPS, and FTP. Here is a detailed introduction to the wget command.
- Basic grammar.
- wget [options] [URL]
- 常见的选择:common options
- -r, –recursive: Download content recursively, allowing you to download an entire website.
-l, –level=depth: Set the depth of recursive downloading.
-k, –convert-links: Convert links in downloaded files to point to local files.
-p, –page-requisites: Download all necessary files for a webpage, including images, CSS files, etc.
-nc, –no-clobber: Do not overwrite existing files.
-P, –directory-prefix=directory: Specify the directory to save downloaded files.
-O, –output-document=file: Specify the filename to save the downloaded file. - Example of use:
- Download a single file:
wget http://example.com/file.txt - Download the entire website content recursively by using the following command:
wget -r http://example.com/ - Set the depth of recursive downloads to 2:
wget -r -l 2 http://example.com/ - Convert the links in the downloaded file to point to local files:
wget -k http://example.com/ - Download all necessary files from the webpage:
wget -p http://example.com/ - Do not overwrite existing files:
wget -nc http://example.com/file.txt - Specify the directory where the downloaded file will be saved:
wget -P /path/to/directory http://example.com/file.txt - Specify the file name for the downloaded file:
wget -O filename http://example.com/file.txt - Please refer to the wget manual for more options and usage information.
- “Use wget”