![](/img/trans.png)
[英]wget -o command output generates more than one file, is it possible to get only one?
[英]Can't get -P and -O flags working together for wget command
wget
版本: 1.21.2 home/ ├─ test/
我遇到了-P
和-O
标志的特定问题,其中-P
标志参数在与-O
标志一起使用时被完全忽略。 例如,我有以下wget
命令:
wget -P test/ -O test.doc https://file-examples.com/wp-content/uploads/2017/02/file-sample_100kB.doc
我正在从主目录运行此命令。 以下是预期和实际结果:
预期结果:
home/
├─ test/
│ ├─ test.doc
实际结果:
home/
├─ test/
test.doc
但是,如果我从命令中删除-O
标志,我会得到预期的结果,当然,它不会被重命名。
wget -P test/ https://file-examples.com/wp-content/uploads/2017/02/file-sample_100kB.doc
结果:
home/
├─ test/
│ ├─ file-sample_100kB.doc
似乎在-P
和-O
标志之间显然发生了一些事情,出于某种原因我不能同时使用它们。
我也尝试过绝对路径,但这对我也没有用。
您可以使用-O -
指示wget
将文件发送到标准 output,然后重定向到目录内的文件考虑以下简单示例
mkdir -p test # create test catalog if it does not exist
wget -O - https://www.example.com > test/example.html
ls test/*.html # shows test/example.html
但是请注意,这将始终下载并覆盖目标文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.