1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Long: output
5Arg: <file>
6Short: o
7Help: Write to file instead of stdout
8Category: important curl
9Added: 4.0
10Multi: append
11See-also:
12  - remote-name
13  - remote-name-all
14  - remote-header-name
15Example:
16  - -o file $URL
17  - "http://{one,two}.example.com" -o "file_#1.txt"
18  - "http://{site,host}.host[1-5].example" -o "#1_#2"
19  - -o file $URL -o file2 https://example.net
20---
21
22# `--output`
23
24Write output to <file> instead of stdout. If you are using {} or [] to fetch
25multiple documents, you should quote the URL and you can use '#' followed by a
26number in the <file> specifier. That variable is replaced with the current
27string for the URL being fetched. Like in:
28
29    curl "http://{one,two}.example.com" -o "file_#1.txt"
30
31or use several variables like:
32
33    curl "http://{site,host}.host[1-5].example" -o "#1_#2"
34
35You may use this option as many times as the number of URLs you have. For
36example, if you specify two URLs on the same command line, you can use it like
37this:
38
39    curl -o aa example.com -o bb example.net
40
41and the order of the -o options and the URLs does not matter, just that the
42first -o is for the first URL and so on, so the above command line can also be
43written as
44
45    curl example.com example.net -o aa -o bb
46
47See also the --create-dirs option to create the local directories
48dynamically. Specifying the output as '-' (a single dash) passes the output to
49stdout.
50
51To suppress response bodies, you can redirect output to /dev/null:
52
53    curl example.com -o /dev/null
54
55Or for Windows:
56
57    curl example.com -o nul
58