xref: /aosp_15_r20/external/curl/docs/cmdline-opts/output.md (revision 6236dae45794135f37c4eb022389c904c8b0090d)
1*6236dae4SAndroid Build Coastguard Worker---
2*6236dae4SAndroid Build Coastguard Workerc: Copyright (C) Daniel Stenberg, <[email protected]>, et al.
3*6236dae4SAndroid Build Coastguard WorkerSPDX-License-Identifier: curl
4*6236dae4SAndroid Build Coastguard WorkerLong: output
5*6236dae4SAndroid Build Coastguard WorkerArg: <file>
6*6236dae4SAndroid Build Coastguard WorkerShort: o
7*6236dae4SAndroid Build Coastguard WorkerHelp: Write to file instead of stdout
8*6236dae4SAndroid Build Coastguard WorkerCategory: important output
9*6236dae4SAndroid Build Coastguard WorkerAdded: 4.0
10*6236dae4SAndroid Build Coastguard WorkerMulti: per-URL
11*6236dae4SAndroid Build Coastguard WorkerSee-also:
12*6236dae4SAndroid Build Coastguard Worker  - remote-name
13*6236dae4SAndroid Build Coastguard Worker  - remote-name-all
14*6236dae4SAndroid Build Coastguard Worker  - remote-header-name
15*6236dae4SAndroid Build Coastguard WorkerExample:
16*6236dae4SAndroid Build Coastguard Worker  - -o file $URL
17*6236dae4SAndroid Build Coastguard Worker  - "http://{one,two}.example.com" -o "file_#1.txt"
18*6236dae4SAndroid Build Coastguard Worker  - "http://{site,host}.host[1-5].example" -o "#1_#2"
19*6236dae4SAndroid Build Coastguard Worker  - -o file $URL -o file2 https://example.net
20*6236dae4SAndroid Build Coastguard Worker---
21*6236dae4SAndroid Build Coastguard Worker
22*6236dae4SAndroid Build Coastguard Worker# `--output`
23*6236dae4SAndroid Build Coastguard Worker
24*6236dae4SAndroid Build Coastguard WorkerWrite output to the given file instead of stdout. If you are using globbing to
25*6236dae4SAndroid Build Coastguard Workerfetch multiple documents, you should quote the URL and you can use `#`
26*6236dae4SAndroid Build Coastguard Workerfollowed by a number in the filename. That variable is then replaced with the
27*6236dae4SAndroid Build Coastguard Workercurrent string for the URL being fetched. Like in:
28*6236dae4SAndroid Build Coastguard Worker
29*6236dae4SAndroid Build Coastguard Worker    curl "http://{one,two}.example.com" -o "file_#1.txt"
30*6236dae4SAndroid Build Coastguard Worker
31*6236dae4SAndroid Build Coastguard Workeror use several variables like:
32*6236dae4SAndroid Build Coastguard Worker
33*6236dae4SAndroid Build Coastguard Worker    curl "http://{site,host}.host[1-5].example" -o "#1_#2"
34*6236dae4SAndroid Build Coastguard Worker
35*6236dae4SAndroid Build Coastguard WorkerYou may use this option as many times as the number of URLs you have. For
36*6236dae4SAndroid Build Coastguard Workerexample, if you specify two URLs on the same command line, you can use it like
37*6236dae4SAndroid Build Coastguard Workerthis:
38*6236dae4SAndroid Build Coastguard Worker
39*6236dae4SAndroid Build Coastguard Worker    curl -o aa example.com -o bb example.net
40*6236dae4SAndroid Build Coastguard Worker
41*6236dae4SAndroid Build Coastguard Workerand the order of the -o options and the URLs does not matter, just that the
42*6236dae4SAndroid Build Coastguard Workerfirst -o is for the first URL and so on, so the above command line can also be
43*6236dae4SAndroid Build Coastguard Workerwritten as
44*6236dae4SAndroid Build Coastguard Worker
45*6236dae4SAndroid Build Coastguard Worker    curl example.com example.net -o aa -o bb
46*6236dae4SAndroid Build Coastguard Worker
47*6236dae4SAndroid Build Coastguard WorkerSee also the --create-dirs option to create the local directories
48*6236dae4SAndroid Build Coastguard Workerdynamically. Specifying the output as '-' (a single dash) passes the output to
49*6236dae4SAndroid Build Coastguard Workerstdout.
50*6236dae4SAndroid Build Coastguard Worker
51*6236dae4SAndroid Build Coastguard WorkerTo suppress response bodies, you can redirect output to /dev/null:
52*6236dae4SAndroid Build Coastguard Worker
53*6236dae4SAndroid Build Coastguard Worker    curl example.com -o /dev/null
54*6236dae4SAndroid Build Coastguard Worker
55*6236dae4SAndroid Build Coastguard WorkerOr for Windows:
56*6236dae4SAndroid Build Coastguard Worker
57*6236dae4SAndroid Build Coastguard Worker    curl example.com -o nul
58*6236dae4SAndroid Build Coastguard Worker
59*6236dae4SAndroid Build Coastguard WorkerSpecify the filename as single minus to force the output to stdout, to
60*6236dae4SAndroid Build Coastguard Workeroverride curl's internal binary output in terminal prevention:
61*6236dae4SAndroid Build Coastguard Worker
62*6236dae4SAndroid Build Coastguard Worker    curl https://example.com/jpeg -o -
63