gpt4 book ai didi

linux - 无法在 while 循环或 if 语句中创建数组?

转载 作者:太空宇宙 更新时间:2023-11-04 05:32:13 24 4
gpt4 key购买 nike

当我尝试在脚本中创建数组时,出现错误。id[1]=string2; 将生成错误 id[1]=string2: not find

我猜这与自从使用 [] 以来我处于 if 语句或 while 循环中的事实有关?我正在运行一个虚拟机,因此附上一张脚本图片,到目前为止,顶部的数组 a[1]=string; 没有生成错误,但逻辑 id[1]=string2; 中的错误却生成了。

enter image description here

最佳答案

作为答案发布,以便可以将此问题标记为已解决:

您的脚本由 sh 执行,而不是 bash。添加正确的 shebang 行作为脚本文件的第一行:

#!/bin/bash

关于linux - 无法在 while 循环或 if 语句中创建数组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9766395/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com