I am trying to use wget
to download a file under a different local name and only download if the file on the server is newer.
What I thought I could do was use the -O
option of wget
so as to be able to choose the name of the downloaded file, as in:
wget http://example.com/weird-name -O local-name
and combine that with the -N
option that doesn't download anything except if the timestamp is newer on the server. For reasons explained in the comments below, wget
refuses to combine both flags:
WARNING: timestamping does nothing in combination with -O. See the manual
for details.
Any ideas on succinct work-arounds ?
Download it, then create a link
wget -N example.com/weird-name
ln weird-name local-name
After that you can run wget -N
and it will work as expected:
If using other tool is possible in your case, I recommend the free, open source lwp-mirror
:
lwp-mirror [-options] <url> <file>
It works just as you wish, with no workarounds.
This command is provided by the libwww-perl
package on Ubuntu and Debian among other places.
Note that lwp-mirror
doesn't support all of wget
's other features. For example, it doesn't allow you to set a User Agent for the request like wget
does.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With