Repeated download jobs need a clear policy for what happens when the destination file already exists. Without one, automation can accumulate confusing duplicates, replace a known-good local copy, or write straight into a fixed output path that downstream jobs already trust.
For standard single-file downloads, GNU wget protects an existing local file by saving the next copy as a numbered sibling such as daily-settlement-2026-03-28.csv.1 instead of overwriting daily-settlement-2026-03-28.csv. The main control switches are --no-clobber (-nc), which skips retrieval when the destination name already exists, and --timestamping (-N), which updates the local copy only when the server version is newer. Current GNU Wget documentation also notes that -nc and -N should not be combined.
The main overwrite risk appears when a fixed output file is forced with --output-document (-O). That path is written directly when the transfer runs, so it should be used only when one canonical local filename is required and the implications are understood before the job is automated.
Steps to prevent overwriting existing files with wget:
- Download the file once so there is a baseline local copy to protect.
$ mkdir -p ~/downloads/daily-settlements $ cd ~/downloads/daily-settlements $ wget https://downloads.example.net/exports/2026-03/daily-settlement-2026-03-28.csv --2026-03-28 14:33:06-- https://downloads.example.net/exports/2026-03/daily-settlement-2026-03-28.csv Resolving downloads.example.net (downloads.example.net)... 203.0.113.50 Connecting to downloads.example.net (downloads.example.net)|203.0.113.50|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 65536 (64K) [text/csv] Saving to: 'daily-settlement-2026-03-28.csv' ##### snipped ##### 2026-03-28 14:33:06 (56.8 MB/s) - 'daily-settlement-2026-03-28.csv' saved [65536/65536]
- Repeat the same command once to observe the default numbered-copy behavior.
$ wget https://downloads.example.net/exports/2026-03/daily-settlement-2026-03-28.csv --2026-03-28 14:33:07-- https://downloads.example.net/exports/2026-03/daily-settlement-2026-03-28.csv Connecting to downloads.example.net (downloads.example.net)|203.0.113.50|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 65536 (64K) [text/csv] Saving to: 'daily-settlement-2026-03-28.csv.1' ##### snipped ##### 2026-03-28 14:33:07 (57.3 MB/s) - 'daily-settlement-2026-03-28.csv.1' saved [65536/65536]
For a normal single-file download, wget avoids clobbering by creating a numbered sibling instead of overwriting the original file.
- Use --no-clobber when the correct behavior is to skip the transfer entirely.
$ wget --no-clobber https://downloads.example.net/exports/2026-03/daily-settlement-2026-03-28.csv File 'daily-settlement-2026-03-28.csv' already there; not retrieving.
-nc prevents both overwriting and extra numbered copies for the same destination name.
- Use --timestamping instead when updates are allowed only for newer server copies.
$ wget --timestamping https://downloads.example.net/exports/2026-03/daily-settlement-2026-03-28.csv --2026-03-28 14:33:08-- https://downloads.example.net/exports/2026-03/daily-settlement-2026-03-28.csv Connecting to downloads.example.net (downloads.example.net)|203.0.113.50|:443... connected. HTTP request sent, awaiting response... 304 Not Modified File 'daily-settlement-2026-03-28.csv' not modified on server. Omitting download.
-N is the better choice when unchanged files should be skipped but newer remote versions should still replace the local copy.
- Guard fixed output filenames carefully when --output-document is required.
$ wget --output-document=daily-settlement-current.csv https://downloads.example.net/exports/2026-03/daily-settlement-2026-03-28.csv --2026-03-28 14:33:09-- https://downloads.example.net/exports/2026-03/daily-settlement-2026-03-28.csv Connecting to downloads.example.net (downloads.example.net)|203.0.113.50|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 65536 (64K) [text/csv] Saving to: 'daily-settlement-current.csv' ##### snipped ##### 2026-03-28 14:33:09 (57.4 MB/s) - 'daily-settlement-current.csv' saved [65536/65536] $ wget --no-clobber --output-document=daily-settlement-current.csv https://downloads.example.net/exports/2026-03/daily-settlement-2026-03-28.csv File 'daily-settlement-current.csv' already there; not retrieving.
--output-document writes to one explicit pathname, so reserve it for jobs that intentionally maintain a single canonical local file.
- Verify the result before handing the directory to other tooling.
$ ls -1 daily-settlement-2026-03-28.csv daily-settlement-2026-03-28.csv.1 daily-settlement-current.csv
The final directory makes the chosen policy visible: one protected original file, one numbered duplicate from an unguarded rerun, and one fixed output path that was skipped on the protected rerun.
Mohd Shakir Zakaria is a cloud architect with deep roots in software development and open-source advocacy. Certified in AWS, Red Hat, VMware, ITIL, and Linux, he specializes in designing and managing robust cloud and on-premises infrastructures.
