curl/docs/cmdline-opts/output.md
Daniel Stenberg 2494b8dd51
docs/cmdline: change to .md for cmdline docs
- switch all invidual files documenting command line options into .md,
   as the documentation is now markdown-looking.

 - made the parser treat 4-space indents as quotes

 - switch to building the curl.1 manpage using the "mainpage.idx" file,
   which lists the files to include to generate it, instead of using the
   previous page-footer/headers. Also, those files are now also .md
   ones, using the same format. I gave them underscore prefixes to make
   them sort separately:
   _NAME.md, _SYNOPSIS.md, _DESCRIPTION.md, _URL.md, _GLOBBING.md,
   _VARIABLES.md, _OUTPUT.md, _PROTOCOLS.md, _PROGRESS.md, _VERSION.md,
   _OPTIONS.md, _FILES.md, _ENVIRONMENT.md, _PROXYPREFIX.md,
   _EXITCODES.md, _BUGS.md, _AUTHORS.md, _WWW.md, _SEEALSO.md

 - updated test cases accordingly

Closes #12751
2024-01-23 14:30:15 +01:00

1.6 KiB

c: Copyright (C) Daniel Stenberg, daniel@haxx.se, et al. SPDX-License-Identifier: curl Long: output Arg: Short: o Help: Write to file instead of stdout Category: important curl Added: 4.0 Multi: append See-also: - remote-name - remote-name-all - remote-header-name Example: - -o file $URL - "http://{one,two}.example.com" -o "file_#1.txt" - "http://{site,host}.host[1-5].example" -o "#1_#2" - -o file $URL -o file2 https://example.net

--output

Write output to instead of stdout. If you are using {} or [] to fetch multiple documents, you should quote the URL and you can use '#' followed by a number in the specifier. That variable is replaced with the current string for the URL being fetched. Like in:

curl "http://{one,two}.example.com" -o "file_#1.txt"

or use several variables like:

curl "http://{site,host}.host[1-5].example" -o "#1_#2"

You may use this option as many times as the number of URLs you have. For example, if you specify two URLs on the same command line, you can use it like this:

curl -o aa example.com -o bb example.net

and the order of the -o options and the URLs does not matter, just that the first -o is for the first URL and so on, so the above command line can also be written as

curl example.com example.net -o aa -o bb

See also the --create-dirs option to create the local directories dynamically. Specifying the output as '-' (a single dash) passes the output to stdout.

To suppress response bodies, you can redirect output to /dev/null:

curl example.com -o /dev/null

Or for Windows:

curl example.com -o nul