Bad variable error while using arrays

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mohangauns
    New Member
    • Oct 2011
    • 3

    Bad variable error while using arrays

    when i read values from user in an array, It displays Bad Variable error.
    code is given below.
    Code:
    count=0
    while [ $count -lt $n ]
    do
     read arr[$count]
     count=`expr $count + 1`
    done
    where n is maximum number of elements in an array.
  • rski
    Recognized Expert Contributor
    • Dec 2006
    • 700

    #2
    Which shell did you use for executing that script. I checked it works ok with bash.

    Comment

    Working...