问题
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