shell 內建命令就是乙個命令或乙個函式,從 shell 中呼叫,它直接在 shell 中執行。 bash shell 直接執行該命令而無需呼叫其他程式。你可以使用 help 命令檢視 bash 內建命令的資訊。以下是幾種不同型別的內建命令。
內建命令的型別
型別如下:
bourne shell 內建命令:內建命令繼承自 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 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 ...]
compgen -b檢視 bash 的內建命令資訊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 命令或 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 ()
command -v ls本文由 lctt 原創翻譯,linux中國 榮譽推出command -v cd
command -v foo
python列出目錄下所有的檔案
import os def listallfilesanddirs level,path files os.listdir path for file in files print level 1 file if os.path.isdir file listallfilesanddirs leve...
列出1 1000內的所有素數(Python)
列出1 1000內的所有素數 python 方法一 判斷乙個數是不是素數 除1和本身之外有沒有其他因數 再利用filter 函式過濾掉非素數 利用filter 函式得到1 1000內的所有素數 思路 判斷乙個數是不是素數,是則留下 不是則濾掉 def prime x for i in range 2...
列出所有的WMI物件方法和屬性vbs指令碼
列出所有的wmi物件方法和屬性vbs指令碼 2009年10月20日 列出所有的wmi物件方法和屬性vbs指令碼 2009年01月21日 星期三 下午 03 16 在powsershell裡面需要使用wmi物件需,找到一段vbs指令碼,能列出所有的wmi資訊,strcomputer set objwm...