Saving cURL output to local files keeps response bodies, download artifacts, and API samples available after terminal scrollback is gone. Saved copies can be inspected later, handed to another tool, or attached to a ticket without repeating the same request.
By default, cURL writes the response body to standard output. --output writes to a chosen filename, --remote-name uses the last path segment from the URL, and --write-out with filename_effective prints the filename that cURL actually wrote.
Local files are overwritten by default when the same target name is reused. --no-clobber and --remove-on-error reduce that risk, but both options require cURL 7.83.0 or later and older systems may reject them as unknown options.
$ curl --silent --output message.txt --write-out '%{filename_effective}\n' https://httpbin.org/base64/SFRUUEJJTiBpcyBhd2Vzb21l
message.txt
filename_effective prints the path that cURL wrote after the transfer finishes.
$ cat message.txt HTTPBIN is awesome
Reading the saved file immediately catches cases where the target path or the returned content is not the data expected.
$ curl --silent --remote-name --write-out '%{filename_effective}\n' https://httpbin.org/robots.txt
robots.txt
--remote-name uses the last path segment from the URL, so this request creates robots.txt in the current directory unless --output-dir is also used.
$ curl --silent --remote-name --no-clobber --write-out '%{filename_effective}\n' https://httpbin.org/robots.txt
robots.txt.1
--no-clobber appends a numeric suffix such as .1 when the original name already exists, and it requires cURL 7.83.0 or later.
$ curl --fail --silent --show-error --remove-on-error --output missing.txt https://httpbin.org/status/404 curl: (56) The requested URL returned error: 404
--fail turns an HTTP error response into a curl failure, and --remove-on-error deletes the incomplete output file instead of leaving stale content behind. The exact curl error code can vary by build or server response.
$ ls missing.txt ls: missing.txt: No such file or directory
If cURL reports unknown option –remove-on-error, the local build is older than 7.83.0 and failed saves need manual cleanup.