Solved

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

Posted on 2006-11-07
4
650 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
xyBalance chalenge 58 93
Expand data scrubbing tool 13 32
WinWaitActive parameters 12 31
Updating statistics with error notification email in SQL server 4 94
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

786 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