Shell编程
保留字
| if | then | elif | else | fi | time |
|---|---|---|---|---|---|
| for | in | until | while | do | done |
| case | esac | coproc | select | function | |
{ | } | [[ | ]] | ! |
变量
运算符
数据结构
数组、关联数组
控制流
- 条件
- if
-eTrue if file exists (regardless of type)-dTrue if file exists and is a directory-fTrue if file exists and is a regular file-nTrue if the length of string is nonzero-zTrue if the length of string is zero
- case
- select
((…))[[…]]
- if
- 循环
- until
until test-commands; do consequent-commands; done - while
while test-commands; do consequent-commands; done - for
for name [ [in [words …] ] ; ] do commands; donefor (( expr1 ; expr2 ; expr3 )) ; do commands ; done
- until
- 分组
(){}
- 协同
函数
fname () compound-command [ redirections ] 或 function fname [()] compound-command [ redirections ]
- 位置参数
${N} - 特殊参数
*@#?-$!0
Shell Expansions
- brace expansion
- tilde expansion
- parameter and variable expansion
- command substitution
- arithmetic expansion
- word splitting
- filename expansion
重定向
内置命令
- Bourne Shell Builtins
- :
- .
- break
- cd
- continue
- eval
- exec
- exit
- export
- false
- getopts
- hash
- pwd
- readonly
- return
- shift
- test
- [
- times
- trap
- true
- umask
- unset
- Bash Builtin Commands
- alias
- bind
- builtin
- caller
- command
- declare
- echo
- enable
- help
- let
- local
- logout
- mapfile
- printf
- read
- readarray
- source
- type
- typeset
- ulimit
- unalias
- Modifying Shell Behavior
- set
- shopt
- Special Builtins