本文介绍了在bash脚本中导出数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不能将数组从bash脚本导出到另一个bash脚本,如下所示:

I can not export an array from a bash script to another bash script like this:

export myArray[0]="Hello"
export myArray[1]="World"

当我这样写没有问题:

export myArray=("Hello" "World")

由于几个原因,我需要将我的数组初始化为多行。你有什么解决方案吗?

For several reasons I need to initialize my array into multiple lines. Do you have any solution?

推荐答案

从ubuntu 10.04下的bash版本4.1.5的联机帮助页。

From the manpage of bash version 4.1.5 under ubuntu 10.04.

以下来自Chet Ramey(目前的bash维护者截至2011年)的声明可能是关于这个bug的最正式的文档:

The following statement from Chet Ramey (current bash maintainer as of 2011) is probably the most official documentation about this "bug":

这篇关于在bash脚本中导出数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 00:50
查看更多