candIDate[1]= 0candIDate[2]= 0candIDate[3]= 0
返回的错误消息是:
Votecalculation.sh: 13: candIDate[1]=: not foundVotecalculation.sh: 14: candIDate[2]=: not foundVotecalculation.sh: 15: candIDate[3]=: not found
在此之后我尝试了另一种在线发现的解决方案
ARRAY=( 'can1' 'can2' 'can3' )
使用它时会返回此错误:
Votecalculation.sh: 12: Syntax error: "(" unexpected
我是Bash的新手,我对阵列感到很困惑.我需要一些特定的方式来声明一个数组,还是我只是完全错了?
解决方法#!/bin/bash myarray[0]=hello myarray[1]=world echo ${myarray[0]} echo ${myarray[1]}
保存到helloworld.bash
执行使用. ./helloword.bash
总结以上是内存溢出为你收集整理的linux – 未找到Bash中的数组全部内容,希望文章能够帮你解决linux – 未找到Bash中的数组所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)