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

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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