linux - 使用wget下载文件
支持http, https, ftp协议进行下载
1. 下载单个文件
wget https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.17.2.tar.xz
2. 将下载的文件重新命名
wget -O latest-hugo.zip https://github.com/gohugoio/hugo/archive/master.zip
3. 将文件下载到指定目录
wget -P /mnt/iso http://mirrors.mit.edu/centos/7/isos/x86_64/CentOS-7-x86_64-Minimal-1804.iso
4. 限制文件下载速度
wget --limit-rate=1m https://dl.google.com/go/go1.10.3.linux-amd64.tar.gz
5. 恢复一个中断的下载
wget -c http://releases.ubuntu.com/18.04/ubuntu-18.04-live-server-amd64.iso
6. 使下载在后台运行
wget -b https://download.opensuse.org/tumbleweed/iso/openSUSE-Tumbleweed-DVD-x86_64-Current.iso
7. 设置用户代理
wget --user-agent="Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0" http://wget-forbidden.com/
8. 一次下载多个文件
wget -i linux-distros.txt
linux-distros.txt
http://mirrors.edge.kernel.org/archlinux/iso/2018.06.01/archlinux-2018.06.01-x86_64.iso
https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-9.4.0-amd64-netinst.iso
https://download.fedoraproject.org/pub/fedora/linux/releases/28/Server/x86_64/iso/Fedora-Server-dvd-x86_64-28-1.1.iso
9. 通过ftp下载文件
wget --ftp-user=FTP_USERNAME --ftp-password=FTP_PASSWORD ftp://ftp.example.com/filename.tar.gz
10. 创建一个网站的镜像
wget -m -k -p https://example.com
11. 跳过证书验证进行https下载
wget --no-check-certificate https://domain-with-invalid-ss.com
12. 下载文件到标准输出,并交给tar命令进行解压,
wget -q -O - "http://wordpress.org/latest.tar.gz" | tar -xzf - -C /var/www