Contents [Hide]
|
变量局部变量和全局变量(环境变量)
declare -i int_var
Bash中的元字符Bash中的元字符是一些有着特殊含意的字符, 在Bash的解释中不是按照字面含意来解释的:
| Charactors | Meaning |
|---|---|
| * ? [ ] ~ + - @ ! | Filename metacharactors |
Filename MetacharactorsIn computer programming, the verb glob or globbing is used to refer to an instance of pattern matching behavior. The noun "glob" is sometimes used to refer to a particular pattern, e.g. "use the glob .log to match all those log files".
Bash用来匹配文件名的元字符:
匹配零个或者多个字符
? 匹配单个字符
[abc...] 匹配包含在集合中任意字符
[!abc...] 匹配不包含在集合中的任意字符
[a-zA-Z0-9] 匹配指定的字符范围中的字符
(可移植性不强,根据区域设置,字符范围可能包含其他字符)
~ 当前用户的Home目录
~name name用户的Home目录
~+ 当前的工作目录($PWD)
~- 上次的工作目录($OLDPWD)
如果打开Bash选项extglob:
?(pattern)
glob
Bash中的特殊字符是由Bash解释的非字面意义的字符(或者字符组):
#: 注释的起始字符;该字符到行末的所有文字都被认为是
注释,注释一旦在一行开始,将无法结束;注释前面可以有有效命令。#!: 具有特殊意义的注释行,用在脚本文件的首行开始处,
指定了可执行脚本文件的解释程序及参数。\: 转义字符,将之后的字符转义为$
.
?
*
[]
()
^
Wiki comments powered by Disqus