?
Solved

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

Posted on 2006-11-07
4
Medium Priority
?
664 Views
Last Modified: 2013-12-26
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...
0
Comment
Question by:swapan2005
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 200 total points
ID: 17894917
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
 
LVL 51

Assisted Solution

by:ahoffmann
ahoffmann earned 200 total points
ID: 17922084
# (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

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question