有时我们使用带有 a = ""
的双连字符(即 ls --hide=desktop
作为参数),有时我们使用单个连字符后跟一个空格(即 find .-type f
)。
这两个选项有什么区别?
最佳答案
因此,当需要单个字符(如“h”或“s”)时,将使用“-”。但是在给出较长的字符串时需要使用双连字符。正如 psusi 所述,有些命令完全违背了这条规则。
在“find”的情况下,您可以看到它试图通过在“-type”后跟一个字符来符合格式。总而言之,答案是“视情况而定。”
如this serverfault post所述:
通过 psusi 回答:
A single hyphen can be followed by multiple single-character flags. A double hyphen prefixes a single, multicharacter option.
通过 ssice 回答:
If there was a "lisa" argument for ls, there would probably have a different meaning to type ls -lisa than ls --lisa. The former are the l, i, s, and a parameters, not the word.
There are also programs that don't obey this convention. Most notably for my sight, dd and gcc.
关于linux - 为我澄清 linux 中的选项 我无法理解 - 和 - 之间的区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55409553/