Linux wget - 输出目录前缀

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8986139/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 04:11:54  来源:igfitidea点击:

Wget - output directory prefix

linuxbashwget

提问by WraithLux

Currently I try to use:

目前我尝试使用:

"wget --user=xxx --password=xxx -r ftp://www.domain.com/htdocs/"

But this saves output files to current directory in this fashion:

但这会以这种方式将输出文件保存到当前目录:

curdir/www.domain.com/htdocs/*

I need it to be:

我需要它是:

curdir/*

Is there a way to do this, I only see a way to use output prefix, but i think this will just allow me to define directory outside current dir?

有没有办法做到这一点,我只看到一种使用输出前缀的方法,但我认为这只会允许我在当前目录之外定义目录?

采纳答案by bkzland

You can combine --no-directoriesif you want all your files inside one directory or --no-host-directoriesto have subdirectories but no subdirectories per host with your --directory-prefixoption.

--no-directories如果您希望所有文件都在一个目录中,或者--no-host-directories每个主机都有子目录但没有子目录,您可以组合使用您的--directory-prefix选项。

2.6 Directory Options

‘-nd' ‘--no-directories' Do not create a hierarchy of directories when retrieving recursively. With this option turned on, all files will get saved to the current directory, without clobbering (if a name shows up more than once, the filenames will get extensions ‘.n').

‘-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.

‘-P prefix' ‘--directory-prefix=prefix' Set directory prefix to prefix. The directory prefix is the directory where all other files and subdirectories will be saved to, i.e. the top of the retrieval tree. The default is ‘.' (the current directory). (From the wget manual.)

2.6 目录选项

'-nd' '--no-directories' 递归检索时不要创建目录层次结构。启用此选项后,所有文件都将保存到当前目录,而不会造成破坏(如果名称出现多次,文件名将获得扩展名“.n”)。

'-nH' '--no-host-directories' 禁用主机前缀目录的生成。默认情况下,使用“-r http://fly.srk.fer.hr/”调用 Wget将创建一个以 fly.srk.fer.hr/ 开头的目录结构。此选项禁用此类行为。

'-P prefix' '--directory-prefix=prefix' 设置目录前缀为前缀。目录前缀是所有其他文件和子目录将保存到的目录,即检索树的顶部。默认值为“.” (当前目录)。(来自wget 手册。)