I/O 重定向与管道
重定向
一般情况下命令从标准输入(stdin)读取输入,并输出到标准输出(stdout),默认情况下两者都是你的终端。使用重定向可以让命令从文件读取输入/输出到文件。下面是以 echo
为例的重定向输出:
$ echo "Hello Linux!" > output_file # 将输出写入到文件(覆盖原有内容)
$ cat output_file
Hello Linux!
$ echo "rewrite it" > output_file
$ cat output_file # 可以看到原来的 Hello Linux! 被覆盖了。
rewrite it
$ echo "append it" >> output_file # 将输出追加到文件(不会覆盖原有内容)
$ cat output_file
rewrite it
append it
>
#将输出写入到文件(覆盖原有内容);
>> #将输出追加到文件(不会覆盖原有内容)
无论是
>
还是>>
,当输出文件不存在时都会创建该文件。
重定向输入使用符号 <
:
command < inputfile
command < inputfile > outputfile
除了 stdin 和 stdout 还有标准错误(stderr),他们的编号分别是 0、1、2。stderr 可以用
2>
重定向(注意数字 2 和 > 之间没有空格)。使用
2>&1
可以将 stderr 合并到 stdout。
管道
管道(pipe),操作符 |
,作用为将符号左边的命令的 stdout 接到之后的命令的 stdin。管道不会处理 stderr。
管道是类 UNIX 操作系统中非常强大的工具。通过管道,我们可以将实现各类小功能的程序拼接起来干大事。 示例如下:
$ ls / | grep bin # 筛选 ls / 输出中所有包含 bin 字符串的行
bin
sbin
网络下载
为何使用 wget 和 cURL
在 Windows 下,很多人下载文件时会使用「X雷」、「XX旋风」(停止运营)之类的软件来实现下载。那么在 Linux 环境下呢?在终端下,没有可视化软件提供点击下载。即使有桌面环境,有 Firefox 可以很方便地下载文件,硬件资源也会被很多不必要的服务浪费。通过以下内容讲述的 wget (wget
) 和 cURL (curl
) 工具,我们可以 Linux 上进行轻量的下载活动。
Wget
wget
是强力方便的下载工具,可以通过 HTTP 和 FTP 协议从因特网中检索并获取文件。
Wget 的特点
-
支持以非交互方式工作,能够在用户注销后在后台进行工作。
-
在不稳定的连接中依旧可以正常工作,支持断点续传功能。
-
支持 HTML 页面以及 FTP 站点的递归检索,您可以使用它来获取网站的镜像,或者像爬虫一样遍历网络。
-
在文件获取时可以增加时间标记,因此可以自动识别远程文件自上次检索后是否发生更改,并自动检索新版本。
-
支持代理服务器,以减轻网络负载,加快检索速度。
使用 Wget
使用 man wget
得到的结果为 wget [option]... [URL]...
,其中的更多参数可以通过查看帮助 wget -h
来获取。
使用示例:
批量下载 filelist.txt 中给出的链接:
$ wget -i filelist.txt
安装 oh-my-zsh:
$ sh -c "$(wget https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"
常用的选项:
选项 | 含义 |
---|---|
-i , --input-file=文件 | 下载本地或外部文件中的 URL |
-O , --output-document=文件 | 将输出写入文件 |
-b , --background | 在后台运行 wget |
-d , --debug | 调试模式,打印出 wget 运行时的调试信息 |
GNU Wget 1.21.2,非交互式的网络文件下载工具。
用法: wget [选项]... [URL]...
长选项所必须的参数在使用短选项时也是必须的。
启动:
-V, --version 显示 Wget 的版本信息并退出
-h, --help 打印此帮助
-b, --background 启动后转入后台
-e, --execute=命令 运行一个“.wgetrc”风格的命令
日志和输入文件:
-o, --output-file=文件 将日志信息写入 FILE
-a, --append-output=文件 将信息添加至 FILE
-d, --debug 打印大量调试信息
-q, --quiet 安静模式 (无信息输出)
-v, --verbose 详尽的输出 (此为默认值)
-nv, --no-verbose 关闭详尽输出,但不进入安静模式
--report-speed=类型 以 <类型> 报告带宽。类型可以是 bits
-i, --input-file=文件 下载本地或外部 <文件> 中的 URL
-F, --force-html 把输入文件当成 HTML 文件
-B, --base=URL 解析相对于 URL 的 HTML 输入文件链接 (-i -F)
--config=文件 指定要使用的配置文件
--no-cookies 不读取任何配置文件
--rejected-log=文件 将拒绝 URL 的原因写入 <文件>。
下载:
-t, --tries=数字 设置重试次数为 <数字> (0 代表无限制)
--retry-connrefused 即使拒绝连接也是重试
--retry-on-http-error=ERRORS 提供以逗号分隔的列表,列出遇到时进行重试的 HTTP 错误
-O, --output-document=文件 将文档写入 FILE
-nc, --no-clobber 不要下载已存在将被覆盖的文件
--no-netrc 不要尝试从 .netrc 获取凭据
-c, --continue 断点续传下载文件
--start-pos=偏移量 从由零计数的 <偏移量> 开始下载
--progress=类型 选择进度条类型
--show-progress 在任意啰嗦状态下都显示进度条
-N, --timestamping 只获取比本地文件新的文件
--no-if-modified-since 不要在时间戳 (timestamping) 模式下使用
if-modified-since get 条件请求
--no-use-server-timestamps 不用服务器上的时间戳来设置本地文件
-S, --server-response 打印服务器响应
--spider 不下载任何文件
-T, --timeout=SECONDS 将所有超时设为 SECONDS 秒
--dns-timeout=SECS 设置 DNS 查寻超时为 SECS 秒
--connect-timeout=SECS 设置连接超时为 SECS 秒
--read-timeout=SECS 设置读取超时为 SECS 秒
-w, --wait=SECONDS wait SECONDS between retrievals
(applies if more then 1 URL is to be retrieved)
--waitretry=SECONDS wait 1..SECONDS between retries of a retrieval
(applies if more then 1 URL is to be retrieved)
--random-wait wait from 0.5*WAIT...1.5*WAIT secs between retrievals
(applies if more then 1 URL is to be retrieved)
--no-proxy 禁止使用代理
-Q, --quota=数字 设置获取配额为 <数字> 字节
--bind-address=ADDRESS 绑定至本地主机上的 ADDRESS (主机名或是 IP)
--limit-rate=RATE 限制下载速率为 RATE
--no-dns-cache 关闭 DNS 查询缓存
--restrict-file-names=系统 限定文件名中的字符为 <系统> 允许的字符
--ignore-case 匹配文件/目录时忽略大小写
-4, --inet4-only 仅连接至 IPv4 地址
-6, --inet6-only 仅连接至 IPv6 地址
--prefer-family=地址族 首先连接至指定家族(IPv6,IPv4 或 none)的地址
--user=用户 将 ftp 和 http 的用户名均设置为 <用户>
--password=密码 将 ftp 和 http 的密码均设置为 <密码>
--ask-password 提示输入密码
--use-askpass=命令 指定用于请求用户名和密码的凭据管理器。
如果没有提供指定命令,程序将使用 WGET_ASKPASS 或
SSH_ASKPASS 环境变量。
--no-iri 关闭 IRI 支持
--local-encoding=ENC 使用 ENC 作为 IRI (国际化资源标识符) 的本地编码
--remote-encoding=ENC 使用 ENC 作为默认远程编码
--unlink 覆盖前移除文件
--xattr 在文件的拓展属性中储存元数据
目录:
-nd, --no-directories 不创建目录
-x, --force-directories 强制创建目录
-nH, --no-host-directories 不要创建主 (host) 目录
--protocol-directories 在目录中使用协议名称
-P, --directory-prefix=前缀 保存文件到 <前缀>/..
--cut-dirs=数字 忽略远程目录中 <数字> 个目录层。
HTTP 选项:
--http-user=用户 设置 http 用户名为 <用户>
--http-password=密码 设置 http 密码为 <密码>
--no-cache 不使用服务器缓存的数据。
--default-page=NAME 改变默认页 (通常是“index.html”)。
-E, --adjust-extension 以合适的扩展名保存 HTML/CSS 文档
--ignore-length 忽略头部的‘Content-Length’区域
--header=字符串 在头部插入 <字符串>
--compression=类型 选择压缩类型,值可以为 auto、gzip 和 none。(默认:none)
--max-redirect 每页所允许的最大重定向
--proxy-user=用户 使用 <用户> 作为代理用户名
--proxy-password=密码 使用 <密码> 作为代理密码
--referer=URL 在 HTTP 请求头包含‘Referer: URL’
--save-headers 将 HTTP 头保存至文件。
-U, --user-agent=代理 标识自己为 <代理> 而不是 Wget/VERSION。
--no-http-keep-alive 禁用 HTTP keep-alive (持久连接)。
--no-cookies 不使用 cookies。
--load-cookies=文件 会话开始前从 <文件> 中载入 cookies。
--save-cookies=文件 会话结束后保存 cookies 至 FILE。
--keep-session-cookies 载入并保存会话 (非永久) cookies。
--post-data=字符串 使用 POST 方式;把 <字串>作为数据发送。
--post-file=文件 使用 POST 方式;发送 <文件> 内容。
--method=HTTP方法 在请求中使用指定的 <HTTP 方法>。
--post-data=字符串 把 <字串> 作为数据发送,必须设置 --method
--post-file=文件 发送 <文件> 内容,必须设置 --method
--content-disposition 当选择本地文件名时允许 Content-Disposition
头部 (实验中)。
--content-on-error 在服务器错误时输出接收到的内容
--auth-no-challenge 不先等待服务器询问就发送基本 HTTP 验证信息。
HTTPS (SSL/TLS) 选项:
--secure-protocol=PR 选择安全协议,值可以是 auto、SSLv2、
SSLv3、TLSv1、TLSv1_1、TLSv1_2 或 PFS
--https-only 只跟随安全的 HTTPS 链接
--no-check-certificate 不要验证服务器的证书。
--certificate=文件 客户端证书文件。
--certificate-type=类型 客户端证书类型,PEM 或 DER。
--private-key=文件 私钥文件。
--private-key-type=类型 私钥文件类型,PEM 或 DER。
--ca-certificate=文件 带有一组 CA 证书的文件。
--ca-directory=DIR 保存 CA 证书的哈希列表的目录。
--ca-certificate=文件 带有一组 CA 证书的文件。
--pinnedpubkey=文件/散列值 用于验证节点的公钥(PEM/DER)文件或
任何数量的 sha256 散列值,以 base64 编码、
“sha256//” 开头、用“;”间隔
--random-file=文件 用于初始化 SSL 伪随机数生成器(PRNG)的文件,
应含有随机数据
--ciphers=STR 直接设置 priority string (GnuTLS) 或 cipher list string (OpenSSL)。
请小心使用。该选项会覆盖 --secure-protocol。
其具体格式和字符串语法取决于对应的 SSL/TLS 引擎。
HSTS 选项:
--no-hsts 禁用 HSTS
--hsts-file HSTS 数据库路径(将覆盖默认值)
FTP 选项:
--ftp-user=用户 设置 ftp 用户名为 <用户>。
--ftp-password=密码 设置 ftp 密码为 <密码>
--no-remove-listing 不要删除‘.listing’文件
--no-glob 不在 FTP 文件名中使用通配符展开
--no-passive-ftp 禁用“passive”传输模式
--preserve-permissions 保留远程文件的权限
--retr-symlinks 递归目录时,获取链接的文件 (而非目录)
FTPS 选项:
--ftps-implicit 使用隐式 FTPS(默认端口 990)
--ftps-resume-ssl 打开数据连接时继续控制连接中的 SSL/TLS 会话
--ftps-clear-data-connection 只加密控制信道;数据传输使用明文
--ftps-fallback-to-ftp 回落到 FTP,如果目标服务器不支持 FTPS
WARC 选项:
--warc-file=文件名 在一个 .warc.gz 文件里保持请求/响应数据
--warc-header=字符串 在头部插入 <字符串>
--warc-max-size=数字 将 WARC 的最大尺寸设置为 <数字>
--warc-cdx 写入 CDX 索引文件
--warc-dedup=文件名 不要记录列在此 CDX 文件内的记录
--no-warc-compression 不要 GZIP 压缩 WARC 文件
--no-warc-digests 不要计算 SHA1 摘要
--no-warc-keep-log 不要在 WARC 记录中存储日志文件
--warc-tempdir=目录 WARC 写入器的临时文件目录
递归下载:
-r, --recursive 指定递归下载
-l, --level=数字 最大递归深度 (inf 或 0 代表无限制,即全部下载)。
--delete-after 下载完成后删除本地文件
-k, --convert-links 让下载得到的 HTML 或 CSS 中的链接指向本地文件
--convert-file-only 只转换 URL 的文件部分(一般叫做“基础名”/basename)
--backups=N 写入文件 X 前,轮换移动最多 N 个备份文件
-K, --backup-converted 在转换文件 X 前先将它备份为 X.orig。
-m, --mirror -N -r -l inf --no-remove-listing 的缩写形式。
-p, --page-requisites 下载所有用于显示 HTML 页面的图片之类的元素。
--strict-comments 用严格方式 (SGML) 处理 HTML 注释。
递归接受/拒绝:
-A, --accept=列表 逗号分隔的可接受的扩展名列表
-R, --reject=列表 逗号分隔的要拒绝的扩展名列表
--accept-regex=REGEX 匹配接受的 URL 的正则表达式
--reject-regex=REGEX 匹配拒绝的 URL 的正则表达式
--regex-type=类型 正则类型 (posix|pcre)
-D, --domains=列表 逗号分隔的可接受的域名列表
--exclude-domains=列表 逗号分隔的要拒绝的域名列表
--follow-ftp 跟踪 HTML 文档中的 FTP 链接
--follow-tags=列表 逗号分隔的跟踪的 HTML 标识列表
--ignore-tags=列表 逗号分隔的忽略的 HTML 标识列表
-H, --span-hosts 递归时转向外部主机
-L, --relative 仅跟踪相对链接
-I, --include-directories=列表 允许目录的列表
--trust-server-names 使用重定向 URL 的最后一段作为本地文件名
-X, --exclude-directories=列表 排除目录的列表
-np, --no-parent 不追溯至父目录
请将问题报告和讨论内容电子邮件发送至 <bug-wget@gnu.org>
和/或在 https://savannah.gnu.org/bugs/?func=additem&group=wget 开 issue 进行讨论。
cURL
cURL (curl
) 是一个利用 URL 语法在命令行下工作的文件传输工具,其中 c 意为 client。虽然 cURL 和 Wget 基础功能有诸多重叠,如下载。但 cURL 由于可自定义各种请求参数,所以在模拟 web 请求方面更擅长;wget 由于支持 FTP 协议和递归遍历,所以在下载文件方面更擅长。
使用 cURL
同 wget
部分,我们可以查看帮助 curl -h
了解其用法。
输出必应主页的代码:
$ curl "http://cn.bing.com"
使用重定向把必应页面保存至
bing.html
本地:$ curl "http://cn.bing.com" > bing.html
也可以使用
-o
选项指定输出文件:$ curl -o bing.html "http://cn.bing.com"
下载 USTCLUG 的 logo:
$ curl -O "https://ftp.lug.ustc.edu.cn/misc/logo-whiteback-circle.png"
只展示 HTTP 响应头内容:
$ curl -I "http://cn.bing.com"
常用的选项:
选项 | 含义 |
---|---|
-o | 把远程下载的数据保存到文件中,需要指定文件名 |
-O | 把远程下载的数据保存到文件中,直接使用 URL 中默认的文件名 |
-I | 只展示响应头内容 |
Usage: curl [options...] <url>
-d, --data <data> HTTP POST data
-f, --fail Fail silently (no output at all) on HTTP errors
-h, --help <category> Get help for commands
-i, --include Include protocol response headers in the output
-o, --output <file> Write to file instead of stdout
-O, --remote-name Write output to a file named as the remote file
-s, --silent Silent mode
-T, --upload-file <file> Transfer local FILE to destination
-u, --user <user:password> Server user and password
-A, --user-agent <name> Send User-Agent <name> to server
-v, --verbose Make the operation more talkative
-V, --version Show version number and quit
This is not the full help, this menu is stripped into categories.
Use "--help category" to get an overview of all categories.
For all options use the manual or "--help all".
Usage: curl [options...] <url>
--abstract-unix-socket <path> Connect via abstract Unix domain socket
--alt-svc <file name> Enable alt-svc with this cache file
--anyauth Pick any authentication method
-a, --append Append to target file when uploading
--aws-sigv4 <provider1[:provider2[:region[:service]]]> Use AWS V4 signature authentication
--basic Use HTTP Basic Authentication
--cacert <file> CA certificate to verify peer against
--capath <dir> CA directory to verify peer against
-E, --cert <certificate[:password]> Client certificate file and password
--cert-status Verify the status of the server cert via OCSP-staple
--cert-type <type> Certificate type (DER/PEM/ENG)
--ciphers <list of ciphers> SSL ciphers to use
--compressed Request compressed response
--compressed-ssh Enable SSH compression
-K, --config <file> Read config from a file
--connect-timeout <fractional seconds> Maximum time allowed for connection
--connect-to <HOST1:PORT1:HOST2:PORT2> Connect to host
-C, --continue-at <offset> Resumed transfer offset
-b, --cookie <data|filename> Send cookies from string/file
-c, --cookie-jar <filename> Write cookies to <filename> after operation
--create-dirs Create necessary local directory hierarchy
--create-file-mode <mode> File mode for created files
--crlf Convert LF to CRLF in upload
--crlfile <file> Use this CRL list
--curves <algorithm list> (EC) TLS key exchange algorithm(s) to request
-d, --data <data> HTTP POST data
--data-ascii <data> HTTP POST ASCII data
--data-binary <data> HTTP POST binary data
--data-raw <data> HTTP POST data, '@' allowed
--data-urlencode <data> HTTP POST data url encoded
--delegation <LEVEL> GSS-API delegation permission
--digest Use HTTP Digest Authentication
-q, --disable Disable .curlrc
--disable-eprt Inhibit using EPRT or LPRT
--disable-epsv Inhibit using EPSV
--disallow-username-in-url Disallow username in url
--dns-interface <interface> Interface to use for DNS requests
--dns-ipv4-addr <address> IPv4 address to use for DNS requests
--dns-ipv6-addr <address> IPv6 address to use for DNS requests
--dns-servers <addresses> DNS server addrs to use
--doh-cert-status Verify the status of the DoH server cert via OCSP-staple
--doh-insecure Allow insecure DoH server connections
--doh-url <URL> Resolve host names over DoH
-D, --dump-header <filename> Write the received headers to <filename>
--egd-file <file> EGD socket path for random data
--engine <name> Crypto engine to use
--etag-compare <file> Pass an ETag from a file as a custom header
--etag-save <file> Parse ETag from a request and save it to a file
--expect100-timeout <seconds> How long to wait for 100-continue
-f, --fail Fail silently (no output at all) on HTTP errors
--fail-early Fail on first transfer error, do not continue
--fail-with-body Fail on HTTP errors but save the body
--false-start Enable TLS False Start
-F, --form <name=content> Specify multipart MIME data
--form-escape Escape multipart form field/file names using backslash
--form-string <name=string> Specify multipart MIME data
--ftp-account <data> Account data string
--ftp-alternative-to-user <command> String to replace USER [name]
--ftp-create-dirs Create the remote dirs if not present
--ftp-method <method> Control CWD usage
--ftp-pasv Use PASV/EPSV instead of PORT
-P, --ftp-port <address> Use PORT instead of PASV
--ftp-pret Send PRET before PASV
--ftp-skip-pasv-ip Skip the IP address for PASV
--ftp-ssl-ccc Send CCC after authenticating
--ftp-ssl-ccc-mode <active/passive> Set CCC mode
--ftp-ssl-control Require SSL/TLS for FTP login, clear for transfer
-G, --get Put the post data in the URL and use GET
-g, --globoff Disable URL sequences and ranges using {} and []
--happy-eyeballs-timeout-ms <milliseconds> Time for IPv6 before trying IPv4
--haproxy-protocol Send HAProxy PROXY protocol v1 header
-I, --head Show document info only
-H, --header <header/@file> Pass custom header(s) to server
-h, --help <category> Get help for commands
--hostpubmd5 <md5> Acceptable MD5 hash of the host public key
--hostpubsha256 <sha256> Acceptable SHA256 hash of the host public key
--hsts <file name> Enable HSTS with this cache file
--http0.9 Allow HTTP 0.9 responses
-0, --http1.0 Use HTTP 1.0
--http1.1 Use HTTP 1.1
--http2 Use HTTP 2
--http2-prior-knowledge Use HTTP 2 without HTTP/1.1 Upgrade
--http3 Use HTTP v3
--ignore-content-length Ignore the size of the remote resource
-i, --include Include protocol response headers in the output
-k, --insecure Allow insecure server connections
--interface <name> Use network INTERFACE (or address)
-4, --ipv4 Resolve names to IPv4 addresses
-6, --ipv6 Resolve names to IPv6 addresses
-j, --junk-session-cookies Ignore session cookies read from file
--keepalive-time <seconds> Interval time for keepalive probes
--key <key> Private key file name
--key-type <type> Private key file type (DER/PEM/ENG)
--krb <level> Enable Kerberos with security <level>
--libcurl <file> Dump libcurl equivalent code of this command line
--limit-rate <speed> Limit transfer speed to RATE
-l, --list-only List only mode
--local-port <num/range> Force use of RANGE for local port numbers
-L, --location Follow redirects
--location-trusted Like --location, and send auth to other hosts
--login-options <options> Server login options
--mail-auth <address> Originator address of the original email
--mail-from <address> Mail from this address
--mail-rcpt <address> Mail to this address
--mail-rcpt-allowfails Allow RCPT TO command to fail for some recipients
-M, --manual Display the full manual
--max-filesize <bytes> Maximum file size to download
--max-redirs <num> Maximum number of redirects allowed
-m, --max-time <fractional seconds> Maximum time allowed for transfer
--metalink Process given URLs as metalink XML file
--negotiate Use HTTP Negotiate (SPNEGO) authentication
-n, --netrc Must read .netrc for user name and password
--netrc-file <filename> Specify FILE for netrc
--netrc-optional Use either .netrc or URL
-:, --next Make next URL use its separate set of options
--no-alpn Disable the ALPN TLS extension
-N, --no-buffer Disable buffering of the output stream
--no-keepalive Disable TCP keepalive on the connection
--no-npn Disable the NPN TLS extension
--no-progress-meter Do not show the progress meter
--no-sessionid Disable SSL session-ID reusing
--noproxy <no-proxy-list> List of hosts which do not use proxy
--ntlm Use HTTP NTLM authentication
--ntlm-wb Use HTTP NTLM authentication with winbind
--oauth2-bearer <token> OAuth 2 Bearer Token
-o, --output <file> Write to file instead of stdout
--output-dir <dir> Directory to save files in
-Z, --parallel Perform transfers in parallel
--parallel-immediate Do not wait for multiplexing (with --parallel)
--parallel-max <num> Maximum concurrency for parallel transfers
--pass <phrase> Pass phrase for the private key
--path-as-is Do not squash .. sequences in URL path
--pinnedpubkey <hashes> FILE/HASHES Public key to verify peer against
--post301 Do not switch to GET after following a 301
--post302 Do not switch to GET after following a 302
--post303 Do not switch to GET after following a 303
--preproxy [protocol://]host[:port] Use this proxy first
-#, --progress-bar Display transfer progress as a bar
--proto <protocols> Enable/disable PROTOCOLS
--proto-default <protocol> Use PROTOCOL for any URL missing a scheme
--proto-redir <protocols> Enable/disable PROTOCOLS on redirect
-x, --proxy [protocol://]host[:port] Use this proxy
--proxy-anyauth Pick any proxy authentication method
--proxy-basic Use Basic authentication on the proxy
--proxy-cacert <file> CA certificate to verify peer against for proxy
--proxy-capath <dir> CA directory to verify peer against for proxy
--proxy-cert <cert[:passwd]> Set client certificate for proxy
--proxy-cert-type <type> Client certificate type for HTTPS proxy
--proxy-ciphers <list> SSL ciphers to use for proxy
--proxy-crlfile <file> Set a CRL list for proxy
--proxy-digest Use Digest authentication on the proxy
--proxy-header <header/@file> Pass custom header(s) to proxy
--proxy-insecure Do HTTPS proxy connections without verifying the proxy
--proxy-key <key> Private key for HTTPS proxy
--proxy-key-type <type> Private key file type for proxy
--proxy-negotiate Use HTTP Negotiate (SPNEGO) authentication on the proxy
--proxy-ntlm Use NTLM authentication on the proxy
--proxy-pass <phrase> Pass phrase for the private key for HTTPS proxy
--proxy-pinnedpubkey <hashes> FILE/HASHES public key to verify proxy with
--proxy-service-name <name> SPNEGO proxy service name
--proxy-ssl-allow-beast Allow security flaw for interop for HTTPS proxy
--proxy-ssl-auto-client-cert Use auto client certificate for proxy (Schannel)
--proxy-tls13-ciphers <ciphersuite list> TLS 1.3 proxy cipher suites
--proxy-tlsauthtype <type> TLS authentication type for HTTPS proxy
--proxy-tlspassword <string> TLS password for HTTPS proxy
--proxy-tlsuser <name> TLS username for HTTPS proxy
--proxy-tlsv1 Use TLSv1 for HTTPS proxy
-U, --proxy-user <user:password> Proxy user and password
--proxy1.0 <host[:port]> Use HTTP/1.0 proxy on given port
-p, --proxytunnel Operate through an HTTP proxy tunnel (using CONNECT)
--pubkey <key> SSH Public key file name
-Q, --quote <command> Send command(s) to server before transfer
--random-file <file> File for reading random data from
-r, --range <range> Retrieve only the bytes within RANGE
--raw Do HTTP "raw"; no transfer decoding
-e, --referer <URL> Referrer URL
-J, --remote-header-name Use the header-provided filename
-O, --remote-name Write output to a file named as the remote file
--remote-name-all Use the remote file name for all URLs
-R, --remote-time Set the remote file's time on the local output
-X, --request <method> Specify request method to use
--request-target <path> Specify the target for this request
--resolve <[+]host:port:addr[,addr]...> Resolve the host+port to this address
--retry <num> Retry request if transient problems occur
--retry-all-errors Retry all errors (use with --retry)
--retry-connrefused Retry on connection refused (use with --retry)
--retry-delay <seconds> Wait time between retries
--retry-max-time <seconds> Retry only within this period
--sasl-authzid <identity> Identity for SASL PLAIN authentication
--sasl-ir Enable initial response in SASL authentication
--service-name <name> SPNEGO service name
-S, --show-error Show error even when -s is used
-s, --silent Silent mode
--socks4 <host[:port]> SOCKS4 proxy on given host + port
--socks4a <host[:port]> SOCKS4a proxy on given host + port
--socks5 <host[:port]> SOCKS5 proxy on given host + port
--socks5-basic Enable username/password auth for SOCKS5 proxies
--socks5-gssapi Enable GSS-API auth for SOCKS5 proxies
--socks5-gssapi-nec Compatibility with NEC SOCKS5 server
--socks5-gssapi-service <name> SOCKS5 proxy service name for GSS-API
--socks5-hostname <host[:port]> SOCKS5 proxy, pass host name to proxy
-Y, --speed-limit <speed> Stop transfers slower than this
-y, --speed-time <seconds> Trigger 'speed-limit' abort after this time
--ssl Try SSL/TLS
--ssl-allow-beast Allow security flaw to improve interop
--ssl-auto-client-cert Use auto client certificate (Schannel)
--ssl-no-revoke Disable cert revocation checks (Schannel)
--ssl-reqd Require SSL/TLS
--ssl-revoke-best-effort Ignore missing/offline cert CRL dist points
-2, --sslv2 Use SSLv2
-3, --sslv3 Use SSLv3
--stderr <file> Where to redirect stderr
--styled-output Enable styled output for HTTP headers
--suppress-connect-headers Suppress proxy CONNECT response headers
--tcp-fastopen Use TCP Fast Open
--tcp-nodelay Use the TCP_NODELAY option
-t, --telnet-option <opt=val> Set telnet option
--tftp-blksize <value> Set TFTP BLKSIZE option
--tftp-no-options Do not send any TFTP options
-z, --time-cond <time> Transfer based on a time condition
--tls-max <VERSION> Set maximum allowed TLS version
--tls13-ciphers <ciphersuite list> TLS 1.3 cipher suites to use
--tlsauthtype <type> TLS authentication type
--tlspassword <string> TLS password
--tlsuser <name> TLS user name
-1, --tlsv1 Use TLSv1.0 or greater
--tlsv1.0 Use TLSv1.0 or greater
--tlsv1.1 Use TLSv1.1 or greater
--tlsv1.2 Use TLSv1.2 or greater
--tlsv1.3 Use TLSv1.3 or greater
--tr-encoding Request compressed transfer encoding
--trace <file> Write a debug trace to FILE
--trace-ascii <file> Like --trace, but without hex output
--trace-time Add time stamps to trace/verbose output
--unix-socket <path> Connect through this Unix domain socket
-T, --upload-file <file> Transfer local FILE to destination
--url <url> URL to work with
-B, --use-ascii Use ASCII/text transfer
-u, --user <user:password> Server user and password
-A, --user-agent <name> Send User-Agent <name> to server
-v, --verbose Make the operation more talkative
-V, --version Show version number and quit
-w, --write-out <format> Use output FORMAT after completion
--xattr Store metadata in extended file attributes
其他
除了 Wget、cURL,还有 mwget(多线程版本 wget)、Axel、Aria2(支持 BT 协议、支持 JSON-RPC 和 XML-RPC 接口远程调用)之类下载工具,其中 Aria2 在 Windows 下使用也很广泛
参考
USTC--101讲义