bug-wget
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-wget] overwrite


From: Tim Rühsen
Subject: Re: [Bug-wget] overwrite
Date: Tue, 13 Jun 2017 16:28:46 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0

Hi Ansgar,


On 06/13/2017 09:40 AM, address@hidden wrote:
>    Hi,
> 
>    a common question online is how to properly force wget to make an
>    overwrite of an existing file name.
> 
>    The existing options are quite confusing and I am under the impression
>    that even taking what works does not imply users understand what they
>    do.
> 
>    The background of my question is
>    https://bugs.winehq.org/show_bug.cgi?id=43100
>    and your section in the manual
> "When running Wget without ‘-N’, ‘-nc’, ‘-r’, or ‘-p’, downloading the same 
> file
>  in the same directory will result in the original copy of file being 
> preserved
> and the second copy being named ‘file.1’. If that file is downloaded yet 
> again,
> the third copy will be named ‘file.2’, and so on."

I admit this is pretty confusing. It's historically grown and we won't
change it to not break existing scripts etc.

>    If I want to disable that default behaviour what option do I take? I go
>    with -nc but I have no clue why I have to take n and c, and online
>    recommendations vary from recommending n, c, and nc.
> 
>    I am looking for something intuitive like:
>    wget --overwrite[1] https://dl.winehq.org/wine-builds/Release.key

There are several possibilities. I personally prefer to make a backup of
existing files before downloading (just in case download stops in the
middle and leaves me with a broken file). That can be used to move an
existing file out of the way:

mv -f Release.key Release.key.bak
wget https://dl.winehq.org/wine-builds/Release.key

Wget can do this without an additional command, even rotates up to an
arbitrary number (see 'man wget'):

wget --backup=3 https://dl.winehq.org/wine-builds/Release.key


But if you still want to replace a file in place (not recommended), you can

wget -O Release.key https://dl.winehq.org/wine-builds/Release.key

or (basically the same)

wget -O- https://dl.winehq.org/wine-builds/Release.key > Release.key


The -nc just switches off saving multiple versions of the file (.1, .2,
...).

Wget is designed not to easily overwrite files resp. to prevent
accidentally overwrites.

>    Best,
>    Ansgar

With Best Regards, Tim

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]