You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
730 B

5 years ago
# **declare**
7 years ago
6 years ago
## 说明
7 years ago
5 years ago
**declare命令** 用于声明和显示已存在的shell变量。当不提供变量名参数时显示所有shell变量。declare命令若不带任何参数选项则会显示所有
shell变量及其值。declare的功能与typeset命令的功能是相同的
7 years ago
5 years ago
## 选项
7 years ago
5 years ago
```markdown
5 years ago
+/-"-"可用来指定变量的属性,"+"则是取消变量所设的属性
-f仅显示函数
r将变量设置为只读
x指定的变量会成为环境变量可供shell以外的程序来使用
i[设置值]可以是数值,字符串或运算式
shell变量声明shell变量格式为“变量名=值”
5 years ago
```
7 years ago
5 years ago
## 实例
7 years ago
5 years ago
```bash
declare test='man.linuxde.net' # 定义并初始化test变量
7 years ago
```