How to Use Wget to Download Only Missing Files in Ubuntu
This article explains how to configure the wget command on Ubuntu to skip existing files and retrieve only new data. You will learn the specific flag that prevents overwriting local data and ensures only missing content is downloaded from the server.
The option that allows wget to download only files that are missing
locally is --no-clobber. You can also use the shorthand
version -nc. When this flag is active, wget checks the
local directory before initiating a transfer. If a file with the same
name already exists, wget skips it entirely rather than overwriting it
or attempting to resume the download.
To use this option, append it to your standard wget command. For example, to download a single file only if it does not exist, run:
wget -nc https://example.com/file.zip
This command is particularly useful when running recursive downloads.
If you are mirroring a website or downloading a directory structure,
adding -nc ensures that you do not waste bandwidth
re-downloading files you already possess. The command looks like
this:
wget -r -nc https://example.com/files/
In this scenario, wget traverses the remote directory but ignores any file that matches a name already present in your local folder. This keeps your local storage efficient and speeds up the synchronization process by focusing solely on missing resources.