Linux/Unix手册页语法约定

sam*_*sam 22 unix linux manpage

man页面中,我遇到了各种语法来编写Linux/Unix命令,其中包括方括号,尖括号,连字符(-)和--各种组合的双连字符().有谁知道这些语法约定的含义?

[ ]
< >
[< >]
[--]
-
--
[< >...]
Run Code Online (Sandbox Code Playgroud)

Avi*_*Avi 38

方括号 [ ]

方括号([])表示包含的元素(参数,值或信息)是可选的.您可以选择一个或多个项目或不选择任何项目.不要在命令行中键入方括号.

例: [global options], [source arguments], [destination arguments]

角支架<>

尖括号(<>)表示包含的元素(参数,值或信息)是必需的.您需要使用适当的信息替换尖括号内的文本.请勿在命令行中键入尖括号.

例: -f [set the File Name variable], -printer <printer name>, -repeat <months> <days> <hours> <minutes>, date access <mm/dd/yyyy>

在类Unix系统中,ASCII连字符 - 减号通常用于指定选项.角色通常后跟一个或多个字母.一个单独的连字符 - 减去其自身没有任何字母的参数通常指定程序应处理来自标准输入的数据或将数据发送到标准输出.在某些程序上使用了两个连字符( - )来指定使用更多描述性选项名称的"长选项".这是GNU软件的常见功能.

只要做'ls --help'并查看选项,它应该是显而易见的.

 -A, --almost-all           do not list implied . and ..
     --author               with -l, print the author of each file
 -b, --escape               print octal escapes for nongraphic characters
     --block-size=SIZE      use SIZE-byte blocks
 -B, --ignore-backups       do not list implied entries ending with ~
 -c                         with -lt: sort by, and show, ctime (time of last
                              modification of file status information)
                              with -l: show ctime and sort by name
                              otherwise: sort by ctime'
 -C                         list entries by columns
     --color[=WHEN] 
Run Code Online (Sandbox Code Playgroud)

  • 您能说出此信息的来源吗?链接会有帮助... (3认同)
  • 非常感谢@Avi ..这些文档和您的回复确实很有帮助。 (2认同)
  • 有人知道是否有标记默认值/参数的约定吗? (2认同)

Dan*_*ski 13

还有一些不常见的{}括号,我搜索的是一个必须以相互排斥的方式指定的选项,例如{-A|--almost-all}.

 "{}" are used in conjunction with a vertical bar to
indicate cases where exactly one of the specified options may be used
Run Code Online (Sandbox Code Playgroud)

https://groups.google.com/forum/#!topic/comp.unix.programmer/XOr31SgvvS8

  • 句子““{}”与竖线结合使用以指示可能使用指定选项之一的情况”是错误的。正确的句子是““{}”与竖线结合使用以指示必须使用指定选项之一的情况”。 (5认同)