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.

  1. Basic grammar.
  2. wget [options] [URL]
  3. 常见的选择:common options
  4. -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.
  5. Example of use:
  6. Download a single file:
    wget http://example.com/file.txt
  7. Download the entire website content recursively by using the following command:
    wget -r http://example.com/
  8. Set the depth of recursive downloads to 2:
    wget -r -l 2 http://example.com/
  9. Convert the links in the downloaded file to point to local files:
    wget -k http://example.com/
  10. Download all necessary files from the webpage:
    wget -p http://example.com/
  11. Do not overwrite existing files:
    wget -nc http://example.com/file.txt
  12. Specify the directory where the downloaded file will be saved:
    wget -P /path/to/directory http://example.com/file.txt
  13. Specify the file name for the downloaded file:
    wget -O filename http://example.com/file.txt
  14. Please refer to the wget manual for more options and usage information.
  15. “Use wget”
bannerAds