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

2019-09-23 08:59:04丽君

另外一种选择是使用下列命令:

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


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

总结

以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,如果有疑问大家可以留言交流,谢谢大家对易采站长站的支持。