curl -o writes the download to a file instead of stdout
Answer: curl --output or -o writes the downloaded body to a given file instead of stdout. curl has several other ways to store and name the downloaded data. If you use globbing in the URL to fetch multiple documents, you can put # followed by a number in the filename.
Errors and partial files
The --remove-on-error option tells curl to delete any partially saved file if curl exits with an error.
Notes
The short help text for --output is "Write to file instead of stdout".
See also
Claims
- id: C1 claim: --output writes output to the given file instead of stdout. source: S2 evidence: "Write output to the given file instead of stdout."
- id: C2 claim: With URL globbing you can use # followed by a number in the filename. source: S2 evidence: "you can use
#followed by a number in the filename"
- id: C3 claim: curl has several other ways to store and name the downloaded data. source: S1 evidence: "curl has several other ways to store and name the downloaded data."
- id: C4 claim: --remove-on-error deletes a partially saved file if curl exits with an error. source: S1 evidence: "It tells curl to delete any partially saved file if curl exits with an error."
Sources
- [S1] Storing downloads. Everything curl. https://everything.curl.dev/usingcurl/downloads/storing.html . License: CC-BY-4.0. Accessed 2026-11-23.
- [S2] --output. curl/curl (GitHub). https://github.com/curl/curl/blob/master/docs/cmdline-opts/output.md . License: curl license (MIT-derived). Accessed 2026-11-23.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Everything curl, Storing downloads; curl/curl (GitHub), --output. CC-BY-4.0 (https://raw.githubusercontent.com/curl/everything-curl/master/LICENSE). Copyright the everything curl authors. curl license (MIT-derived) (https://raw.githubusercontent.com/curl/curl/master/COPYING). Copyright (c) 1996 - 2026, Daniel Stenberg, and many contributors. Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Everything curl, Storing downloads; curl/curl (GitHub), --output. CC-BY-4.0 (https://raw.githubusercontent.com/curl/everything-curl/master/LICENSE). Copyright the everything curl authors. curl license (MIT-derived) (https://raw.githubusercontent.com/curl/curl/master/COPYING). Copyright (c) 1996 - 2026, Daniel Stenberg, and many contributors.
Cite this
iinventedlight. 2026. "curl -o writes the download to a file instead of stdout." iinventedlight Library, iil:note:v662e37e, version of 2026-11-23. https://iinventedlight.com/library/notes/curl-save-output/. License: CC-BY-4.0.
@misc{iil_note_v662e37e,
author = {{iinventedlight}},
title = {{curl -o writes the download to a file instead of stdout}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-23},
url = {https://iinventedlight.com/library/notes/curl-save-output/},
note = {Permanent ID iil:note:v662e37e. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
Extra files beside this note
These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.
- curl-save-output.schema.json (schema; CC-BY-4.0)
- curl-save-output.table.json (table; CC-BY-4.0)
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/curl-save-output.md.