且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

“-"的魔力是什么?(破折号)在命令行参数中?

更新时间:2022-04-28 04:54:06

如果您指的是 tar 命令末尾的裸露 -,这在许多命令中都很常见想要使用文件.

If you mean the naked - at the end of the tar command, that's common on many commands that want to use a file.

它允许您指定标准输入或输出而不是实际文件名.

It allows you to specify standard input or output rather than an actual file name.

您的第一个和第三个示例就是这种情况.例如,cdrecord 命令采用标准输入(由 mkisofs 生成的 ISO 映像流)并将其直接写入 /dev/dvdrw.

That's the case for your first and third example. For example, the cdrecord command is taking standard input (the ISO image stream produced by mkisofs) and writing it directly to /dev/dvdrw.

使用cd 命令,每次更改目录时,它都会存储您来自的目录.如果您使用特殊的 -目录名称"执行 cd,它会使用记住的目录而不是真实的目录.使用它,您可以轻松地在两个目录之间快速切换.

With the cd command, every time you change directory, it stores the directory you came from. If you do cd with the special - "directory name", it uses that remembered directory instead of a real one. You can easily switch between two directories quite quickly by using that.

其他命令可能会将 - 视为 不同的 特殊值.

Other commands may treat - as a different special value.