Hi Ansgar,
On 06/13/2017 09:40 AM, [email protected] 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
signature.asc
Description: OpenPGP digital signature
