国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > Linux Shell > 正文

列出所有Bash Shell內置命令的方法示例

2020-07-27 18:49:01
字體:
來源:轉載
供稿:網友

前言

Shell有很多內置在其源代碼中的命令。這些命令是內置的,所以Shell不必到磁盤上搜索它們,執行速度因此加快。不同的Shell內置命令有所不同。

內置命令包含在 bash shell 本身里面。我該如何在 Linux / Apple OS X / *BSD / Unix 類操作系統列出所有的內置 bash 命令,而不用去讀大篇的 bash 操作說明頁?

shell 內置命令就是一個命令或一個函數,從 shell 中調用,它直接在 shell 中執行。 bash shell 直接執行該命令而無需調用其他程序。你可以使用 help 命令查看 Bash 內置命令的信息。以下是幾種不同類型的內置命令。

內置命令的類型

  • Bourne Shell 內置命令:內置命令繼承自 Bourne Shell。
  • Bash 內置命令:特定于 Bash 的內置命令表。
  • 修改 Shell 行為:修改 shell 屬性和可選行為的內置命令。
  • 特別的內置命令:由 POSIX 特別分類的內置命令。

如何查看所有 bash 內置命令

有以下的命令:

$ help$ help | less$ help | grep read 

樣例輸出:

GNU bash, version 4.1.5(1)-release (x86_64-pc-linux-gnu)These shell commands are defined internally. Type `help' to see this list.Type `help name' to find out more about the function `name'.Use `info bash' to find out more about the shell in general.Use `man -k' or `info' to find out more about commands not in this list. A star (*) next to a name means that the command is disabled.  job_spec [&]              history [-c] [-d offset] [n] or hist> (( expression ))            if COMMANDS; then COMMANDS; [ elif C> . filename [arguments]         jobs [-lnprs] [jobspec ...] or jobs > :                    kill [-s sigspec | -n signum | -sigs> [ arg... ]               let arg [arg ...] [[ expression ]]            local [option] name[=value] ... alias [-p] [name[=value] ... ]     logout [n] bg [job_spec ...]            mapfile [-n count] [-O origin] [-s c> bind [-lpvsPVS] [-m keymap] [-f filen> popd [-n] [+N | -N] break [n]                printf [-v var] format [arguments] builtin [shell-builtin [arg ...]]    pushd [-n] [+N | -N | dir] caller [expr]              pwd [-LP] case WORD in [PATTERN [| PATTERN]...)> read [-ers] [-a array] [-d delim] [-> cd [-L|-P] [dir]            readarray [-n count] [-O origin] [-s> command [-pVv] command [arg ...]    readonly [-af] [name[=value] ...] or> compgen [-abcdefgjksuv] [-o option] > return [n] complete [-abcdefgjksuv] [-pr] [-DE] > select NAME [in WORDS ... ;] do COMM> compopt [-o|+o option] [-DE] [name ..> set [--abefhkmnptuvxBCHP] [-o option> continue [n]              shift [n] coproc [NAME] command [redirections]  shopt [-pqsu] [-o] [optname ...] declare [-aAfFilrtux] [-p] [name[=val> source filename [arguments] dirs [-clpv] [+N] [-N]         suspend [-f] disown [-h] [-ar] [jobspec ...]     test [expr] echo [-neE] [arg ...]          time [-p] pipeline enable [-a] [-dnps] [-f filename] [na> times eval [arg ...]             trap [-lp] [[arg] signal_spec ...] exec [-cl] [-a name] [command [argume> true exit [n]                type [-afptP] name [name ...] export [-fn] [name[=value] ...] or ex> typeset [-aAfFilrtux] [-p] name[=val> false                  ulimit [-SHacdefilmnpqrstuvx] [limit> fc [-e ename] [-lnr] [first] [last] o> umask [-p] [-S] [mode] fg [job_spec]              unalias [-a] name [name ...] for NAME [in WORDS ... ] ; do COMMAND> unset [-f] [-v] [name ...] for (( exp1; exp2; exp3 )); do COMMAN> until COMMANDS; do COMMANDS; done function name { COMMANDS ; } or name > variables - Names and meanings of so> getopts optstring name [arg]      wait [id] hash [-lr] [-p pathname] [-dt] [name > while COMMANDS; do COMMANDS; done help [-dms] [pattern ...]        { COMMANDS ; }

另外一種選擇是使用下列命令:

compgen -bcompgen -b | more

查看 Bash 的內置命令信息

運行以下得到詳細信息:

help commandhelp read

要僅得到所有帶簡短描述的內置命令的列表,執行如下:

$ help -d

查找內置命令的語法和其他選項

使用下列語法去找出更多的相關內置命令:

help name help cd help fg help for help read help :

樣例輸出:

:: : Null command.  No effect; the command does nothing.  Exit Status: Always succeeds

找出一個命令是內部的(內置)還是外部的

使用 type 命令或 command 命令:

type -a command-name-here type -a cd type -a uname type -a : type -a ls

或者:

type -a cd uname : ls uname

樣例輸出:

cd is a shell builtinuname is /bin/uname: is a shell builtinls is aliased to `ls --color=auto'ls is /bin/lsl is a functionl (){ ls --color=auto}

或者:

command -V ls command -V cd command -V foo


View list bash built-ins command info on Linux or Unix

總結

以上就是這篇文章的全部內容了,希望本文的內容對大家的學習或者工作具有一定的參考學習價值,如果有疑問大家可以留言交流,謝謝大家對武林網的支持。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 思茅市| 原阳县| 双鸭山市| 交口县| 大厂| 无棣县| 宁晋县| 卓尼县| 沂南县| 娄底市| 安龙县| 淳化县| 昔阳县| 南澳县| 沛县| 德昌县| 泰宁县| 海宁市| 航空| 曲阜市| 新疆| 株洲县| 永川市| 湖州市| 章丘市| 翁源县| 蕉岭县| 汝阳县| 铜山县| 霍州市| 广宗县| 凯里市| 湛江市| 文水县| 布拖县| 巴里| 泰顺县| 淮南市| 南平市| 绥滨县| 阜平县|