Linux/Unix Bash Shell列出所有内置命令
时间:2020-01-09 10:42:05 来源:igfitidea点击:
bash shell本身包含了内置命令。
如何在Linux/Apple OS X/* BSD/Unix等操作系统上列出所有内置的bash命令,而不阅读大型bash手册页?
内置的Shell只是从shell本身直接执行的命令或者从shell调用的函数。
bash shell直接执行命令,而无需调用其他程序。
您可以使用" help"命令查看Bash内置信息。
有不同类型的内置命令。
内置命令类型
- Bourne Shell Builtins:从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 ; }
另一种选择是使用NA命令:
compgen -b compgen -b | more
查看内置Bash的信息
要获取详细信息,请运行:
help command help 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 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