濮阳杆衣贸易有限公司

主頁(yè) > 知識(shí)庫(kù) > 列出所有Bash Shell內(nèi)置命令的方法示例

列出所有Bash Shell內(nèi)置命令的方法示例

熱門標(biāo)簽:申請(qǐng)400電話有什么用 網(wǎng)絡(luò)電話外呼系統(tǒng)撥號(hào)軟件 宿松高德地圖標(biāo)注 電銷機(jī)器人加盟多少錢 4層電梯外呼控制系統(tǒng)設(shè)計(jì) 400電話申請(qǐng)找 天津智能外呼系統(tǒng)排名 貴陽(yáng)400電話到哪里去辦理 汨羅代理外呼系統(tǒng)

前言

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

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

shell 內(nèi)置命令就是一個(gè)命令或一個(gè)函數(shù),從 shell 中調(diào)用,它直接在 shell 中執(zhí)行。 bash shell 直接執(zhí)行該命令而無(wú)需調(diào)用其他程序。你可以使用 help 命令查看 Bash 內(nèi)置命令的信息。以下是幾種不同類型的內(nèi)置命令。

內(nèi)置命令的類型

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

如何查看所有 bash 內(nèi)置命令

有以下的命令:

$ 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 -b
compgen -b | more

查看 Bash 的內(nèi)置命令信息

運(yùn)行以下得到詳細(xì)信息:

help command
help read

要僅得到所有帶簡(jiǎn)短描述的內(nèi)置命令的列表,執(zhí)行如下:

$ help -d

查找內(nèi)置命令的語(yǔ)法和其他選項(xiàng)

使用下列語(yǔ)法去找出更多的相關(guān)內(nèi)置命令:

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

樣例輸出:

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

找出一個(gè)命令是內(nèi)部的(內(nèi)置)還是外部的

使用 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 builtin
uname is /bin/uname
: is a shell builtin
ls is aliased to `ls --color=auto'
ls is /bin/ls
l is a function
l ()
{
 ls --color=auto
}

或者:

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


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

總結(jié)

以上就是這篇文章的全部?jī)?nèi)容了,希望本文的內(nèi)容對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,如果有疑問(wèn)大家可以留言交流,謝謝大家對(duì)腳本之家的支持。

您可能感興趣的文章:
  • 如何在Linux中自定義bash命令提示符
  • Linux中10個(gè)方便的Bash別名
  • Linux 中糾正拼寫錯(cuò)誤的Bash 命令方法
  • bash命令使用詳解

標(biāo)簽:贛州 烏蘭察布 廣東 昌都 臨沂 撫州 連云港 海北

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《列出所有Bash Shell內(nèi)置命令的方法示例》,本文關(guān)鍵詞  列出,所有,Bash,Shell,內(nèi)置,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《列出所有Bash Shell內(nèi)置命令的方法示例》相關(guān)的同類信息!
  • 本頁(yè)收集關(guān)于列出所有Bash Shell內(nèi)置命令的方法示例的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    开原市| 和静县| 剑川县| 新安县| 鄂州市| 廉江市| 忻城县| 兴业县| 万载县| 汾西县| 昭苏县| 浦北县| 洛扎县| 湖北省| 宁城县| 韶山市| 宜君县| 库伦旗| 莒南县| 汶川县| 绥德县| 米易县| 乡城县| 黔西县| 临洮县| 宁蒗| 平乡县| 穆棱市| 昌图县| 阿瓦提县| 嘉黎县| 东兴市| 沅陵县| 广昌县| 瓦房店市| 花莲市| 海伦市| 明光市| 崇仁县| 荆州市| 韶山市|