linux - bash中使用 "declare -a"声明数组有什么好处?

标签 linux arrays bash shell

使用 declare -a 声明数组有什么好处?

例如;使用 declare -a foo=(a b c) 是否比使用 foo=(a b c) 有任何好处?

最佳答案

当您在 bash 中声明一个变量时,它就变成了局部作用域。这与使用内置的 local 相同。在范围界定之外,没有任何好处。必须在 bash 中声明的唯一变量是带有 -A 的关联数组。

关于linux - bash中使用 "declare -a"声明数组有什么好处?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15235906/

相关文章:

java - 无法理解这个 findMinimum 数组方法

linux - 使用列名称而不是数字来过滤条件

JavaScript 混淆 : Objects vs. 数组与对象数组?

c++ - 命名空间 ‘std’ 中的“ostream”未命名类型

javascript - AngularJS 下拉菜单不显示选定的值

linux - 如何使用多个正则表达式在 Solaris 中查找文件

bash:/usr/local/sphinx/bin/search:没有这样的文件或目录

bash - 在命令替换中转义 AWK 中的反斜杠

c - 重启参数 RB_HALT_SYSTEM 和 RB_POWER_OFF 有什么区别?

linux - 启动容器进程导致 "exec: >\"exec\": executable file not found in $PATH": unknown