Skip to content
Latchkey

curl -o / -O: Save the Response to a File

By default curl prints to stdout, so saving an artifact means -o or -O.

Downloading a build artifact, installer, or release asset is a daily CI task. The two output flags differ in where the file lands.

What it does

-o / --output <file> writes the response body to the named file. -O / --remote-name saves it under the filename from the URL. Use -o when you control the name, -O for convenience. --create-dirs makes any missing directories in the -o path. By default curl writes the body to stdout.

Common usage

Terminal
curl -o build.tar.gz https://artifacts.example.com/build.tar.gz
curl -O https://artifacts.example.com/build.tar.gz   # saves as build.tar.gz
curl -L -o dist/app.zip --create-dirs https://example.com/app.zip
curl -fL -o installer.sh https://example.com/install.sh

Flags

FlagWhat it does
-o / --output <file>Write the body to a named file
-O / --remote-nameSave using the filename from the URL
--create-dirsCreate missing parent directories for -o
-L / --locationFollow redirects (needed for many CDNs)
-C - / --continue-atResume a partial download

In CI

Pair downloads with -fL: -f so a 404 fails the step instead of writing an HTML error page into your artifact, and -L because release and CDN URLs usually redirect. Without -f, you can end up extracting an error page as if it were a tarball.

Common errors in CI

A "not in gzip format" error from tar after curl usually means -f was missing and you saved an HTML 404 page. Warning: Failed to create the file means the -o path directory does not exist; add --create-dirs.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →