在 Linux 终端中,破折号是否可以用作临时文件名?

In Linux Terminal is it a dash sign can be use as a temporary filename?

我是 Linux 的新手,我正在学习 nmap,我对破折号有疑问,我在教程中看到一行命令是

nmap -oG - 1.2.3.4 -p 22 -vv > /home/TEST

我的问题是-oG选项后需要一个文件名,但是如果使用破折号作为选项的文件名为什么可以跳过?是因为破折号是临时文件或其他东西的意思吗?它也不会在 /home/ 目录中创建名为“-”的文件。

表示 stdout,在您的示例中为 /home/TEST。您也可以只使用:

nmap -oG /home/TEST 1.2.3.4 -p 22 -vv

来自 man nmap(部分 "Output"):

... While these options save results to files, Nmap still prints interactive output to stdout as usual. For example, the command nmap -oX myscan.xml target prints XML to myscan.xml and fills standard output with the same interactive results it would have printed if -oX wasn't specified at all. You can change this by passing a hyphen character as the argument to one of the format types. This causes Nmap to deactivate interactive output, and instead print results in the format you specified to the standard output stream. So the command nmap -oX - target will send only XML output to stdout.. Serious errors may still be printed to the normal error stream, stderr. ...