無法在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 个解决方案

#1


2  

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.

外部實用程序如date本身與Bash沒有任何關系,即使您可以從Bash調用它們。

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

    對於任何給定的外部實用程序,您將在其特定的man和info頁面(如果已安裝)中找到文檔,正如您所發現的那樣。

  • 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:

雖然只有info(沒有參數)會顯示一個外部實用程序的列表,通常在單個實用程序的標題下,有一些問題;取決於您的系統:

  • 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.

    但是,如果您的系統是一個Linux發行版,它確實使用GNU實用程序(這是標准),而info命令是與bash一起提供的,那么您可能沒問題。

  • 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:

    獲取外部實用程序列表的另一種方法是查閱posix授權的實用程序集;注意,這個列表將僅僅是安裝在大多數現代平台上的實用程序的子集;類似地,單個實用程序描述通常只描述給定平台版本的實用程序的-標准化子集,因為大多數實用程序實現非標准擴展:

    • 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:

    下面的命令將輸出$PATH中所有可執行文件的列表(可以是一個很長的列表);還請注意,列表通常包括定制安裝的實用程序;列表將包含完整路徑,按目錄分組:

    • 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.
      • 例如,在一個特定的文件夾中。
    • 要發現給定文件夾中的所有可執行文件,請在當前文件夾中使用:./ 。例如,在一個特定的文件夾中。

注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2016/02/28/18923d37b64cfbdc5529221fefbd6ac1.html



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