Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Arrays 为数组赋值(Bash脚本错误)_Arrays_Bash - Fatal编程技术网

Arrays 为数组赋值(Bash脚本错误)

Arrays 为数组赋值(Bash脚本错误),arrays,bash,Arrays,Bash,我被告知,可以使用以下代码在bash脚本中同时为数组赋值: arrayName[0]=1 但是,这对我不起作用,并且不断抛出这个错误: 数组[0]=1:未找到 有人能指出我的错误吗你确定你做的正是数组[0]=1?在表达式的任何一方面都有额外的空间会破坏它。在Cygwin的bash中,我对它没有任何问题。你能提供更多关于该错误的上下文吗?在我的msysgit bash shell中,我对此没有问题。你能确定你正在运行bash(哈哈,jk)吗?你确定你的间距和我们在这里看到的完全一样吗?/bin/s

我被告知,可以使用以下代码在bash脚本中同时为数组赋值:

arrayName[0]=1

但是,这对我不起作用,并且不断抛出这个错误:

数组[0]=1:未找到


有人能指出我的错误吗

你确定你做的正是
数组[0]=1
?在表达式的任何一方面都有额外的空间会破坏它。

在Cygwin的bash中,我对它没有任何问题。你能提供更多关于该错误的上下文吗?在我的msysgit bash shell中,我对此没有问题。你能确定你正在运行bash(哈哈,jk)吗?你确定你的间距和我们在这里看到的完全一样吗?
/bin/sh
在你的系统中可能不是bash。请使用
#重试/bin/bash
,并在实际问题中使用代码标记发布代码,以便更好地检测格式错误。