wget
wget是常用下载工具
wget 指定下载目录
wget下载文件到指定目录
-P prefix-P prefix --directory-prefix=prefix Set directory prefix to prefix. The directory prefix is the directory where all other files and sub-directories will be saved to, i.e. the top of the retrieval tree. The default is . (the current directory).
举例:
wget <file.ext> -P /path/to/folder
wget 指定下载后文件名
wget下载文件到指定目录下文件名
-O filename-O file --output-document=file The documents will not be written to the appropriate files, but all will be concatenated together and written to file. If - is used as file, documents will be printed to standard output, disabling link conversion. (Use ./- to print to a file literally named -.)
举例:
wget <file.ext> -O /path/to/folder/file.ext
wget 镜像网站目录
wget镜像网站目录 -m ,不过如果单纯使用这个参数可能会下载太多的非目标网站的内容(毕竟每个页面链接可能引用了太多站外内容),所以通常会结合一些限制参数:
--mirror(-m): 递归下载资源--convert-links(-k) : 转换所有链接(例如CSS),以适合离线浏览--adjust-extension(-E): 根据文件内容为文件添加后缀(html或css)--page-requisites(-p): 下载页面离线显示需要的CSS以及图片--no-parent(-np) : 当执行递归时不上升到父目录,这对于限制仅下载网站的部分内容很有用
这里最重要的结合参数是 --no-parent ,避免下载太多不必要的内容
上述参数的组合可以缩写为 -mkEpnp 举例,在 在SLES 15 sp4中部署GlusterFS 11客户端 时,从官方仓库镜像下载 gluster-11 rpm包:
按照文件中url内容来下载文件
在 LFS准备工作 中采用一个url列表文件来下载对应软件包:
下载所有 wget-list-sysv 列出的软件包和补丁
wget --input-file=wget-list-sysv --continue --directory-prefix=$LFS/sources
wget 代理
wgetrc 配置
/etc/wgetrc 或者 ~/.wgetrc 都可以为 wget 配置代理:
/etc/wgetrc 或者 ~/.wgetrc 配置代理use_proxy = on
http_proxy = http://username:password@proxy.server.address:port/
https_proxy = http://username:password@proxy.server.address:port/
ftp_proxy = http://username:password@proxy.server.address:port/
命令行参数
wget 命令的 -e 参数可以传递 wgetrc 配置,这样就可以代替配置文件:
直接命令行
-e 参数传递代理配置wget -e use_proxy=yes -e http_proxy=$proxy http://askubuntu.com