How To store values in array by reading input in UNIX shell pgm

can anyone please tell me how to declare and read values into an array in Unix shell pgm.
like if i want to find  prime numbers between  1 to 300 and put the prime numbers in an array and then using loop to retrieve the array elemnts...
swapan2005Asked:
Who is Participating?
 
ozoCommented:
I don't know which shell you are using, but in bash or ksh you can do
array=(2 3 5 7 11 13 17)
echo ${array[3]}
0
 
ahoffmannCommented:
# (t)csh syntax:
set arr = (1 2 3 4 5 6 7 8 9)

# sh syntax
arr[1]=1
arr[2]=2
# or see previous suggestion)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.