使用 wget 递归获取包含任意文件的目录 [英] Using wget to recursively fetch a directory with arbitrary files in it
问题描述
我有一个 Web 目录,用于存储一些配置文件.我想使用 wget 将这些文件拉下来并保持它们当前的结构.例如,远程目录看起来像:
I have a web directory where I store some config files. I'd like to use wget to pull those files down and maintain their current structure. For instance, the remote directory looks like:
http://mysite.com/configs/.vim/
.vim 包含多个文件和目录.我想使用 wget 在客户端上复制它.似乎无法找到正确的 wget 标志组合来完成这项工作.有什么想法吗?
.vim holds multiple files and directories. I want to replicate that on the client using wget. Can't seem to find the right combo of wget flags to get this done. Any ideas?
推荐答案
您必须将 -np
/--no-parent
选项传递给 wget
(当然除了-r
/--recursive
),否则会按照我站点上目录索引中的链接到父目录.所以命令看起来像这样:
You have to pass the -np
/--no-parent
option to wget
(in addition to -r
/--recursive
, of course), otherwise it will follow the link in the directory index on my site to the parent directory. So the command would look like this:
wget --recursive --no-parent http://example.com/configs/.vim/
为避免下载自动生成的 index.html
文件,请使用 -R
/--reject
选项:
To avoid downloading the auto-generated index.html
files, use the -R
/--reject
option:
wget -r -np -R "index.html*" http://example.com/configs/.vim/
这篇关于使用 wget 递归获取包含任意文件的目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!