Does “ - ” mean stdout in bash?

后端 未结 4 1671
迷失自我
迷失自我 2020-12-10 04:25

Is \" - \" a shortcut for stdout in bash? If not what does it mean? For example,

wget -q -O - $line 

How about stdin?

Thanks and re

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-10 05:10

    As far as I know, bash isn't involved with the usage of dash. It's just a convention of many UNIX command line utilities to accept - as a placeholder for stdin or stdout when put in place of an input or output file name on the command line.


    Edit: found it, this behavior is specified in the POSIX Utility Syntax Guidelines, §12.2.13 of The Open Group Base Specifications:

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

提交回复
热议问题