NGa*_*bit 32 download directory-structure files
我有一个配置文件,其中包含我要下载的 URI 列表。例如,
http://xyz.abc.com/Dir1/Dir3/sds.exe
http://xyz.abc.com/Dir2/Dir4/jhjs.exe
http://xyz.abc.com/Dir1/itr.exe
Run Code Online (Sandbox Code Playgroud)
我想读取配置文件并复制每个 URL,但同时创建与主机上相同的目录结构。例如,对于配置文件中的第一行,我想在我的本地机器上创建目录结构 Dir1/Dir3(如果它不存在),然后将 sds.exe 复制到 .../Dir1/Dir3/
我发现我可以使用 'wget -i' 下载文件中的所有 URL,但是如何使用它创建相应的目录结构
Chr*_*own 36
来自man wget:
-x, --force-目录:
[...]
创建一个目录层次结构,即使否则不会创建一个目录。例如 wget -x http://fly.srk.fer.hr/robots.txt会将下载的文件保存到 fly.srk.fer.hr/robots.txt。
小智 29
为了获得您要求的结构,我建议使用 -nH 和 -x。
这将删除主机名并创建预期的目录结构。
例如
wget -x -nH http://xyz.abc.com/Dir1/Dir3/sds.exe
- 'Dir1/Dir3/sds.exe' saved [1234]
Run Code Online (Sandbox Code Playgroud)
从手册页:
-nH
--no-host-directories
Disable generation of host-prefixed directories. By default, invoking Wget with -r http://fly.srk.fer.hr/ will create a structure of directories beginning with fly.srk.fer.hr/. This option disables such behavior.
-x
--force-directories
...create a hierarchy of directories, even if one would not have been created otherwise...
Run Code Online (Sandbox Code Playgroud)