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