| Shells |
|---|
bash
| GNU 開發的 Bourne-Again Shell
ksh
Korn shell
pdksh
Public Domain Korn Shell
sh
原始 Bourne Shell
zsh
Z-shell
|
bash
| The GNU Project's Bourne-Again Shell.
ksh
The Korn shell, either an original or clone, depending upon the
operating system.
pdksh
The Public Domain Korn shell.
sh
The original Bourne shell, particularly on commercial Unix systems.
zsh
The Z-shell.
|
| 系統內建指令 |
|---|
| 指令 | 意義
:
不做事,單純傳回'0'結束值(執行成功)
·
將後面帶的字串當作 Shell script 請Current Shell 執行之
break
自涵括的 for, while 或 until 指令迴圈中跳出 (如果有的話)
cd
將現行目錄變更至指定的目錄
continue
回復涵括的 for、while 或 until 指令迴圈的下一個回合
echo
將後面帶的字串於 STDOUT 印出
eval
將後面帶的字串作為指令由一個新的子程序執行之
exec
將後面帶的字串作為指令由Current
Shell的程序執行之,任務結束時,該程序立即中止。
(一個可能的應用是: 換一個自己喜歡的Shell,踢掉原有的Shell)
exit <n>
中止Current Shell,並指定結束狀態為 'n'
export
將變數設為環境變數
hash
記住指令的路徑以加速指令的執行
pwd
顯示現行目錄
read
從標準輸入讀取一行
readonly
將變數設定為唯讀
return
結束函數,並傳回 exit code
set
顯示所有變數及其內容
shift
將位置變數向左移 n 位
test
評估條件表示式
times
顯示執行 shell 之處理程序的使用者和系統累計次數
trap
當 shell 收到指定的信號時,執行指定的指令
type
解釋 shell 會以何種方式
執行
(內建指令,或外部指令的完整路徑)
ulimit
顯示或調整配置的 shell 資源
umask
設定所有新建檔案的預設權限
unset
移除變數或函數
wait
等待指定的子程序結束,或報告它的終止狀態
|
|---|
| Built-in Commands (English) |
|---|
.
| Read and execute a given file, in the current shell.
break
Break out of a for, select, until, or while loop.
cd
Change the current directory.
command
Bypass the search for functions to run a regular built-in command.
continue
Start the next iteration of a for, select, until, or while loop.
eval
Evaluate given text as a shell command.
exec
With no arguments, change the shell's open files. With arguments,
replace the shell with another program.
exit
Exit a shell script, optionally with a specific exit code.
export <var>
Export a variable into the environment of subsequent programs.
false
Do nothing, unsuccessfully. For use in shell loops.
getopts
Process command-line options.
read
Read lines of input into one or more shell variables.
readonly
Mark a variable as read-only; i.e., unchangeable.
return
Return a value from a shell function.
set
Print shell variables and values; set shell options; set the
command-line parameters ($1, $2, ...).
shift
Move the command-line parameters down by one or more.
test
Evaluate expressions, which may be string-, numeric-, or
file-attribute-related.
trap
Manage operating system signals.
true
Do nothing, successfully. For use in shell loops.
type
Indicate the nature of a command (keyword, built-in, external, etc.).
typeset
Declare variables and manage their type and attributes.
ulimit
Set or display various per-process system-imposed limits.
unset
Remove shell variables and functions.
|
| Some Useful Commands |
|---|
|
The following commands are useful in day-to-day shell scripting:
|
basename
| Print the last component of a pathname, optionally removing a
suffix. Mainly used in command substitution.
dirname
Print all but the last component of a pathname. Mainly used in
command substitution.
env
Manipulate the environment of a command.
id
Print user and group ID and name information.
date
Print the current date and time, optionally under control of a
user-supplied format string.
who
Print a list of logged-on users.
stty
Manipulate the state of the current terminal device.
|