无法在info bash中找到“日期”命令的描述——找到所有可以从shell中调用的命令的列表

[英]Can't find description for 'date' command in info bash - find a list of all commands callable from the shell

I'll mention this first - the goal of this question is really to bolster my understanding of bash and the info bash pages rather than to get specific answers on the functionality of the date command.

我将首先提到这个问题——这个问题的目的实际上是增强我对bash和info bash页面的理解,而不是对日期命令的功能得到具体的答案。

I'm unable to find any mention of the date command from the following indices of the info bash manual:

我无法从以下的info bash手册的索引中找到日期命令:

  • Builtin Index:: Index of Bash builtin commands.
  • 内建索引:Bash内建命令的索引。
  • Reserved Word Index:: Index of Bash reserved words.
  • 保留字索引:Bash保留字索引。
  • Variable Index:: Quick reference helps you find the variable you want.
  • 变量索引:快速引用可以帮助您找到所需的变量。
  • Function Index:: Index of bindable Readline functions.
  • 函数索引:可绑定的Readline函数的索引。

However, I'm able to get information on the date function with info date. This page seems to a part of the BSD General Commands Manual but I'm unable to find the index page of this manual - if I go to the containing node though typing 'u' this takes me to the 'dir' page rather than an general command index as I would expect.

但是,我可以用info date函数获取关于日期的信息。这个页面似乎BSD将军命令手册的一部分但我无法找到本手册的索引页,如果我去包含节点输入“u”这个带我去“dir”页面,而不是总指挥部指数如我所想。

My main concern here is that if I can't find information on the date command within info bash, then what other commands aren't listed within info bash? Is there a comprehensive list of all of the commands I can use within Bash?

我在这里主要关心的是,如果我在info bash中找不到日期命令的信息,那么info bash中没有列出其他哪些命令?在Bash中,我可以使用的所有命令是否都有一个完整的列表?

1 个解决方案



info bash and man bash only document Bash's own features.

info bash和man bash仅记录bash自己的特性。

External utilities such as date have nothing to with Bash per se, even though you can call them from Bash.


  • For any given external utility you'll find documentation in its specific man and info pages (if installed), as you've discovered.


  • What muddles the issue is that Bash has so-called builtins that look and behave like external utilities in many respects - those have specific help topics that you can invoke with help; e.g., help read, but you can also find them in man bash under the heading SHELL BUILTIN COMMANDS.
    Furthermore, some command names, e.g. echo, exist both as Bash builtins and as external utilities (/bin/echo).

    让问题变得复杂的是,Bash有所谓的内建,在许多方面看起来和行为上都类似于外部实用程序——它们有特定的帮助主题,您可以通过帮助调用它们;例如,帮助阅读,但是你也可以在man bash中,在SHELL内置命令的标题下找到它们。此外,一些命令名(例如echo)作为Bash内置程序和外部实用程序(/bin/echo)存在。

While just info (without arguments) will show you a list of external utilities, typically under heading Individual utilities, there are problems; depending on your system:


  • The list may be incomplete, or spread across multiple locations.


  • The documentation may not refer to the actual utilities installed on your system.


    • For instance, on OSX the info topics document the GNU core utilities, whereas OSX mostly comes with BSD utilities.
    • 例如,在OSX上,info主题为GNU核心实用程序编写文档,而OSX主要提供BSD实用程序。
  • If, however, your system is a Linux distro that does use the GNU utilities (which is the norm) and the info command is the one that came with bash, you may be fine.


  • See below for commands that allow you to find all external utilities in your $PATH.


  • An alternative way to get a list of external utilities is to consult the set of POSIX-mandated utilities; note that this list will only be a subset of the set of utilities installed on most modern platforms; similarly, the individual utility description will typically only describe the - standardized - subset of a given platform's version of that utility, because most utilities implement nonstandard extension:


    • Go to Shell & Utilities: Detailed Toc and search for heading Utilities (as the full heading), which lists all external utilities a POSIX-compliant system must have.I couldn't find a direct link to a page listing all utilities by name.
    • 转到Shell & Utilities:详细的Toc和搜索标题实用程序(作为完整的标题),它列出了与posix兼容的系统必须具有的所有外部实用程序。我找不到一个直接链接到一个按名字列出所有实用程序的页面。
    • POSIX also mandates the builtins (built-in utilities) that a POSIX-compliant shell must implement (of which the Bash builtins are a superset):
    • POSIX还要求兼容POSIX的shell必须实现的内置程序(其中Bash内置程序是超集):内置实用程序特殊的内置实用程序

Additional information:


  • To see whether a given command is a builtin, use, e.g.:
  • 查看给定的命令是否为内置命令,请使用。
 $ type read
 read is a shell builtin
  • To see all forms of a command, use option -a, e.g.:
  • 要查看命令的所有形式,请使用选项a,例如:
 $ type -a read
 read is a shell builtin
 read is /usr/bin/read

How to find all (external) utilities in your $PATH:


  • The following command will output a list of all executables in your $PATH (this can be a long list); also note that the list will typically include utilities that were custom-installed; the list will contain full paths, grouped by directory:


    • The command looks for files that are executable by the o (other, rest of the word) security principal, which all preinstalled utilities should be; conceivably, there are additional utilities that have the permissions attribute only for the u and/or g principal.
    • 该命令查找可执行的文件,这些文件由o(其他的词)安全主体执行,所有预先安装的实用程序都应该是该安全主体;可以想象,还有一些附加的实用程序只具有u和/或g主体的权限属性。
printf '%s' "$PATH" | tr ':' '\n' | xargs -I {} find {} -maxdepth 1 -type f -perm -o=x
  • If you want a sorted list of mere executable names, use:
  • 如果你想要一个仅仅是可执行名称的排序列表,使用:
printf '%s' "$PATH" | tr ':' '\n' | xargs -I {} find {} -maxdepth 1 -type f -perm -o=x |
  awk -F/ '{ print $NF }' | sort -u
  • The above lists only unique names; it is possible for distinct duplicates of executables with the same filename to exist in multiple directories in the $PATH (in which case the one whose directory comes first in $PATH "wins"); to see a list of duplicates, prefixed with their occurrence count, use:
  • 以上列出的只是唯一的名称;可以在$PATH中以相同的文件名在多个目录中存在不同的可执行文件副本(在这种情况下,其目录在$PATH中第一次获得“赢”);要查看重复的列表,使用它们的发生计数,使用:
printf '%s' "$PATH" | tr ':' '\n' | xargs -I {} find {} -maxdepth 1 -type f -perm -o=x |
  awk -F/ '{ print $NF }' | sort | uniq -c | grep -v ' *1'
  • For any given name with duplicates you can use which -a <name> to see the full paths of all duplicates.
  • 对于任何具有重复的给定名称,可以使用which -a 来查看所有重复名称的完整路径。

Finally, tab completion can be helpful in discovering commands:


  • Type man and press the Tab key repeatedly to list / cycle through all command; specify a command prefix - e.g., man dat - to only list / cycle through the commands that start with that prefix (the exact behavior depends on your readline configuration).

    输入man,重复按Tab键,通过所有命令列表/循环;指定一个命令前缀——例如,man dat—只通过从该前缀开始的命令来列出/循环(确切的行为取决于您的readline配置)。

    • By default this does not work with info (at least on the OSX and Ubuntu systems that I've tried this on from Bash).
    • 默认情况下,这不能处理信息(至少在我在Bash中尝试过的OSX和Ubuntu系统上)。
  • This also works when starting to type a command name to invoke.


    • However, that requires typing at least one letter, which limits the matches to commands whose name starts with that letter.
    • 但是,这需要输入至少一个字母,这将匹配限制为名称以该字母开头的命令。
    • To discover all executables in a given folder, use:
      • ./<tab> in the current folder.
      • ./ 在当前文件夹中。
      • /usr/bin/<tab>, for instance, in a specific folder.
      • 例如,在一个特定的文件夹中。
    • 要发现给定文件夹中的所有可执行文件,请在当前文件夹中使用:./ 。例如,在一个特定的文件夹中。



  © 2014-2022 ITdaan.com 联系我们: