linux - 为我澄清 linux 中的选项 我无法理解 - 和 - 之间的区别?

标签 linux

有时我们使用带有 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/

相关文章:

python - 使用 python-evdev 将事件发送到 uinput 关于掩码键的键绑定(bind)问题

python - 关于 python "#!usr/bin/env python"?

c++ - 我的析构函数是否给我这个错误 : *** Error in `./main' : double free or corruption (fasttop):?

linux - 基于协议(protocol)(UDP、TCP 等)在 Linux 上模拟丢包

linux - Ubuntu 16.04 linux-crashdump 失败

c++ - LINUX 中库/可执行文件的大小很大

java - 如何使用 Tomcat 8 在 Linux 上安装 Quercus

linux - 如何通过串行到 USB 连接将文件从 Windows 机器复制到 Linux 板?

linux - 用 bash 解析 .env 文件

php - 将 iPhone HTTP 请求发送到 Apache PHP 网络服务器