brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: curl --skip-existing leaves a file alone when it is already there

Curl
~/tips/tip-curl-skip-existing

curl --skip-existing --create-dirs --parallel --remote-name-all \

Makes curl skip a download when a file with that name already exists locally.

For a script I run again and again, the cheapest download is the one that does not happen. --skip-existing tells curl to skip a file that is already on disk.

The manual says that if a local file is present when a download is requested, the operation is skipped. That makes a rerunnable fetch script simple:

curl --skip-existing --create-dirs --parallel --remote-name-all \
  --output-dir /mnt/user/appdata/<app>/archive \
  https://example.com/2026-01.csv https://example.com/2026-02.csv

Run it twice and the second run only fetches files that are not there yet. The option was added in curl 8.10.0, so an older curl will reject it as an unknown option. Check curl --version first.

The related --no-clobber option does something different. With it, curl does not overwrite an existing file but saves the new download under a different name by adding a dot and a number, up to 9999. The manual says that from curl 8.23.0 a name with an extension gets -1, -2 and so on before the extension, so image.jpg becomes image-1.jpg. So --skip-existing means no new download, --no-clobber means a new download next to the old one.

The caveat is written in the manual itself: curl cannot know whether the local file was downloaded completely or is the leftover of a broken transfer. It only checks whether a file with that name exists. If an earlier run was interrupted, the broken file stays and is skipped forever. I would pair it with --remove-on-error, so a failed download does not leave something behind that looks finished, or compare a checksum afterwards.

For files that change on the server, this is the wrong tool. Use --etag-compare or --time-cond there.

Further reading: curl man page: –skip-existing and –no-clobber

More Curl tips curl --trace-ascii – https://example.com/ Retry-After: 120 curl -fsS --fail-early \ url = "https://example.com/data/latest.json" curl -4 -s -o /dev/null -w '%{remote_ip} %{http_code}\n' https://example.com/ All Curl tips (71) All topics

Link