4

What is the meaning of -D -? I only found out -C - in the curl docs.

curl -s -D - \
  -H "Referer:https://yahoo.com" \
  "https://something.com"
Charles Duffy
  • 280,126
  • 43
  • 390
  • 441
angelokh
  • 9,426
  • 9
  • 69
  • 139
  • 2
    Dumps the headers to stdout. Pro tip: `man curl | grep -C 5 -- -D` (Grep the man page for `-D` and include 5 lines before and after.) `-` usually represents stdout. See for instance the `-o` option. "Specifying the output as '-' (a single dash) will force the output to be done to stdout." – aioobe May 10 '16 at 17:45
  • 1
    Possible duplicate of [Does " - " mean stdout in bash?](http://stackoverflow.com/questions/3797795/does-mean-stdout-in-bash) (note that part of the answer was "no, this has nothing to do with bash"). – Charles Duffy May 10 '16 at 17:53

1 Answers1

5

See the POSIX utility conventions document:

Guideline 13: For utilities that use operands to represent files to be opened for either reading or writing, the '-' operand should be used to mean only standard input (or standard output when it is clear from context that an output file is being specified) or a file named -.

Thus, when - is used in a filename context, it is compliant with POSIX conventions to read or write the relevant data from stdin or stdout, as appropriate.

Charles Duffy
  • 280,126
  • 43
  • 390
  • 441