wget:尾部破折号 represent/do 是什么意思?
wget: what does this trailing dash represent/do?
wget http://ipinfo.io/ip -qO -
我是 bash
的新手,似乎无法弄清楚结尾的短划线字符的作用(或者为什么此命令中需要它)。
非常感谢任何帮助。
在通常是您的终端的 STDOUT 上打印输出。
See the manpage for wget which says :
-O file
--output-document=file
The documents will not be written to the appropriate files, but all will be concatenated together and written to file. If - is
used as file, documents will be printed to standard output, disabling
link conversion. (Use ./- to print to a file literally named -.)
按照惯例(并非所有程序都遵循),文件名位置中的破折号视情况指代标准输入或标准输出。由于这是 -O
(输出)的参数,因此它指的是标准输出。
更详细的写法(在 Linux 或其他操作系统上 /dev/stdout
可以被除 shell 以外的程序使用)是:
wget http://ipinfo.io/ip --quiet --output-document=/dev/stdout
碰巧,这种行为是由 POSIX Utility Syntax Guidelines 定义的。具体来说:
Guideline 5:
One or more options without option-arguments, followed by at most one option that takes an option-argument, should be accepted when grouped behind one '-' delimiter.
...因此,-qO
与 -q -O
.
的处理方式相同
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 -.
...因此,关于 -
的行为是明确指定的。
wget http://ipinfo.io/ip -qO -
我是 bash
的新手,似乎无法弄清楚结尾的短划线字符的作用(或者为什么此命令中需要它)。
非常感谢任何帮助。
在通常是您的终端的 STDOUT 上打印输出。
See the manpage for wget which says :
-O file --output-document=file The documents will not be written to the appropriate files, but all will be concatenated together and written to file. If - is used as file, documents will be printed to standard output, disabling link conversion. (Use ./- to print to a file literally named -.)
按照惯例(并非所有程序都遵循),文件名位置中的破折号视情况指代标准输入或标准输出。由于这是 -O
(输出)的参数,因此它指的是标准输出。
更详细的写法(在 Linux 或其他操作系统上 /dev/stdout
可以被除 shell 以外的程序使用)是:
wget http://ipinfo.io/ip --quiet --output-document=/dev/stdout
碰巧,这种行为是由 POSIX Utility Syntax Guidelines 定义的。具体来说:
Guideline 5: One or more options without option-arguments, followed by at most one option that takes an option-argument, should be accepted when grouped behind one '-' delimiter.
...因此,-qO
与 -q -O
.
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 -.
...因此,关于 -
的行为是明确指定的。