2019-09-06 10:05:52 3389浏览
大家都知道不同的Shell内置命令有所不同,所以本篇文章扣丁学堂Linux培训小编就给大家简单介绍一下关于如何列出所有Bash Shell内置命令的相关资料,感兴趣的小伙伴就随小编来一起学习学习吧。
前言
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内置命令
有以下的命令:
样例输出:
另外一种选择是使用下列命令:
查看 Bash 的内置命令信息
运行以下得到详细信息:
要仅得到所有带简短描述的内置命令的列表,执行如下:
查找内置命令的语法和其他选项
使用下列语法去找出更多的相关内置命令:
样例输出:
找出一个命令是内部的(内置)还是外部的
使用 type 命令或 command 命令:
或者:
样例输出:
或者:
$ 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
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 -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
想要了解更多关于Linux开发方面内容的小伙伴,请关注扣丁学堂Linux培训官网、微信等平台,扣丁学堂IT职业在线学习教育有专业的Linux讲师为您指导,此外扣丁学堂老师精心推出的Linux视频教程定能让你快速掌握Linux从入门到精通开发实战技能。扣丁学堂Linux技术交流群:422345477。
【关注微信公众号获取更多学习资料】 【扫码进入JavaEE/微服务VIP免费公开课】