wget – How to Allow Overwriting Files

centoscommand-line-interfacelinuxredhatwget

Using wget command, how do I allow/instruct to overwrite my local file everytime, irrespective of how many times I invoke.

Let's say, I want to download a file from the location: http://server/folder/file1.html

Here, whenever I say wget http://server/folder/file1.html, I want this file1.html to be overwritten in my local system irrespective of the time it is changed, already downloaded, etc. My intention/use case here is that when I call wget, I'm very sure that I want to replace/overwrite the existing file.

I've tried out the following options, but each option is intended/meant for some other purpose.

  1. -nc => –no-clobber
  2. -N => Turn on time-stamping
  3. -r => Turn on recursive retrieving

Best Answer

wget -q http://www.whatever.com/filename.txt -O /path/filename.txt 

-q is quiet mode so you can throw it in a cron without any output from the command