Is it possible to run wget using both -O and -P options together?

拈花ヽ惹草 提交于 2020-07-22 09:47:50

问题


I want to download a program. For example "package.zip"

I want to download it in, for example "~/programs/downloaded"

I want to name it, for example "new.zip"

So I tried:

wget -P ~/programs/downloaded \
     -O new.zip   https://somewebsite.com/package.zip

But it only downloaded the package in the terminal's current directory and renamed it. The -P command does not work. Any idea how to make it work?


回答1:


This is a feature of wget that has bitten many people. Unfortunately, it was a design decision taken many years ago and cannot be changed now for fear of breaking existing scripts. The crucial thing to understand here is that -O acts like shell redirection and hence is unaffected by the -P option.

The way to do what you want would be to directly provide the filename:

wget -O ~/programs/downloaded/new.zip <url>


来源:https://stackoverflow.com/questions/55473784/is-it-possible-to-run-wget-using-both-o-and-p-options-together

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!