Solved

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

Posted on 2006-11-07
4
641 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
4 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 50 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 50 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

707 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now