【发布时间】:2016-01-03 06:16:45
【问题描述】:
在 Unix 或类似 Unix 的系统中,命令是“shell builtin”的类型。像 cd、echo 这样的命令是 shell 内置的。有没有什么办法 列出所有的 shell 内置命令或者是否有任何命令可以列出 shell 的所有内置命令?
【问题讨论】:
在 Unix 或类似 Unix 的系统中,命令是“shell builtin”的类型。像 cd、echo 这样的命令是 shell 内置的。有没有什么办法 列出所有的 shell 内置命令或者是否有任何命令可以列出 shell 的所有内置命令?
【问题讨论】:
查找您的 shell 的手册页。 应该有一个“SHELL BUILTIN COMMANDS”部分
$ man bash
【讨论】:
这取决于外壳。因此,请阅读您的特定 shell 的文档。
对于bash,请参阅here。
对于zsh,请参阅here。
对于fish,请参阅this。
对于tcsh(我不推荐,STFW 对于csh considered harmful),请参阅here。
有关 POSIX shell 规范,请阅读 that。如果您想以某种方式编写“可移植” shell 脚本,则应将自己限制在该规范中。
一些救援 shell 有许多内置函数,在严重损坏或损坏的系统上很有用,例如没有更多 /bin/mv 或 /bin/cp executables。例如sash。
一些 shell 能够加载 plugins(不知何故可能定义新的内置函数),或定义函数。
一些 shell 有一个 restricted 形式,它删除一些内置函数(特别是 cd)。对于受限的bash,请参阅here。
【讨论】:
bash。它不适用于其他外壳。如果您的bash 已经加载了插件,那将是不完整的,或者对于受限的bash 来说可能过多
TAB 显示来自 PATH 和内置命令的可用命令。
重置你的 PATH 并输入 [TAB] 两次并回答 y
$ PATH=
$ [TAB][TAB]
Display all 123 possibilities? (y or n)
- compgen fg _ooexp_ spwd
: complete fi path startx
! compopt for _pkcon _strip
. _compreply_ function __pkconcomp suspend
.. continue _gdb_ _pkcon_search test
... coproc getopts popd then
[ __dbus_send hash ppwd time
[[ declare help printf times
]] dir history pushd trap
{ dirs if pwd true
} disown in rd type
+ do jobs read typeset
alias done kill readarray ulimit
beep echo l readonly umask
bg elif la rehash unalias
bind else let remount unmount
break enable ll return unset
builtin esac local _scout until
caller eval logout _scpm wait
case exec ls select while
cd exit ls-l set _yast2
_cd_ _exp_ _man_ shift you
cd.. export mapfile shopt _zypper
command false md skipthis
command_not_found_handle fc o source
【讨论】:
只需在shell上输入help,就会出现一个列表
【讨论】: