03-31-2009
How to display values from user input array?
Hi all,
I wrote a script that reads inputs from user and store in array named "input". The number of elements in the array is not fixed - determined only after user exit the while loop that reads the array values :
x=1
echo "Enter first value"
read input[$x]
while [ ${input[$x]} != "exit" ]
do
x=$((x + 1))
echo "Another value? (type exit to end) "
read input[$x]
done
Then I would like to print each of the array contents from input[1] until user exits. How can I do that?
Using for i in $input does not work for me.. please guide
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Dear Friends,
I am doing a sh shell script , But I dont have any idea how to read value from user Keyboard and store them to an array .. Is it possible or not I am not also sure in sh shell script ?
EX:-
#! /bin/sh
read DATA
echo "DATA -" $DATA
echo "DATA -" $DATA
echo "DATA... (7 Replies)
Discussion started by: user_prady
7 Replies
2. Shell Programming and Scripting
how can i only display the result according to user input?
For example:
i have a data file(in the attachement), when the user enter "1" it will only display whole records with pid from the data file matches to the users entered. (13 Replies)
Discussion started by: thms_sum
13 Replies
3. Shell Programming and Scripting
Hello,
Can somebody please give me a snippet for the below requirement.
I want to assign the values separeted by a comma to be assigned to a dynamic array.
If I give an input (read statement) like abc1,abc2,abc3,abc4,abc5, all these strings abc* should be assigned to an array like below... (2 Replies)
Discussion started by: suneelj
2 Replies
4. Shell Programming and Scripting
Is there a way to display the default answer when accepting input from the user in the unix script..
e.g.
ans="n"
read $ans?"Enter y to continue n to exit:"
altough ans contains n the message doesn't display the current contents on ans .. you get
Enter y to continue n to exit: (8 Replies)
Discussion started by: flopster
8 Replies
5. Shell Programming and Scripting
What I am doing is creating a top menu, which a user will select a choice with a number entry. That number corresponds to a string in an array. I then want to assign that response to another array I've already declared.
For example:
#!/bin/bash
colors=(red blue yellow)
red=(cherry fire)... (2 Replies)
Discussion started by: Akilleez
2 Replies
6. Shell Programming and Scripting
Hi, How to create array every time user input and store user input and display all array
print " Enter input "
my @input = split(' ', $input)
chmop($input = <STDIN>;
foreach ($input)
{
@array= @input;
}
print @array"\n"; (1 Reply)
Discussion started by: guidely
1 Replies
7. Programming
I have a program that accepts user input. For example I have mdacc that the user sets the value. I then have a class which stores the value set by the user. I use set_param to set the values in the class. I pass through it the list of user defines arguments from argv. What would be the opinion on... (0 Replies)
Discussion started by: kristinu
0 Replies
8. Shell Programming and Scripting
Hi, i am very new to php Is it possible to display Range of date depend on user input day
example:
user input 2 day start from 28/4/12 it will add 2 day from date of input
so display should look like this
28/4/12 to 30/4/12
then from 30/412 user add another 4 date so will... (0 Replies)
Discussion started by: guidely
0 Replies
9. Shell Programming and Scripting
Hello,
I need to capture multiple values from user input and do not know how to do it. I'm writing a script to delete old files, but want to give the option to keep some by asking the user.
This is what my output looks like...
Old files to be deleted...
1 file1
2 file2
Then this bit of... (3 Replies)
Discussion started by: jrymer
3 Replies
10. Shell Programming and Scripting
Hello,
I am running under ubuntu1 14.04 and I have a script which is sending given process names to vanish so that I'd see less output when I run most popular tools like top etc in terminal window. In usual method it works.
Whenever I restart the system, I have to enter the same data from... (2 Replies)
Discussion started by: baris35
2 Replies
CGTSV(l) ) CGTSV(l)
NAME
CGTSV - solve the equation A*X = B,
SYNOPSIS
SUBROUTINE CGTSV( N, NRHS, DL, D, DU, B, LDB, INFO )
INTEGER INFO, LDB, N, NRHS
COMPLEX B( LDB, * ), D( * ), DL( * ), DU( * )
PURPOSE
CGTSV solves the equation A*X = B, where A is an N-by-N tridiagonal matrix, by Gaussian elimination with partial pivoting.
Note that the equation A'*X = B may be solved by interchanging the order of the arguments DU and DL.
ARGUMENTS
N (input) INTEGER
The order of the matrix A. N >= 0.
NRHS (input) INTEGER
The number of right hand sides, i.e., the number of columns of the matrix B. NRHS >= 0.
DL (input/output) COMPLEX array, dimension (N-1)
On entry, DL must contain the (n-1) subdiagonal elements of A. On exit, DL is overwritten by the (n-2) elements of the second
superdiagonal of the upper triangular matrix U from the LU factorization of A, in DL(1), ..., DL(n-2).
D (input/output) COMPLEX array, dimension (N)
On entry, D must contain the diagonal elements of A. On exit, D is overwritten by the n diagonal elements of U.
DU (input/output) COMPLEX array, dimension (N-1)
On entry, DU must contain the (n-1) superdiagonal elements of A. On exit, DU is overwritten by the (n-1) elements of the first
superdiagonal of U.
B (input/output) COMPLEX array, dimension (LDB,NRHS)
On entry, the N-by-NRHS right hand side matrix B. On exit, if INFO = 0, the N-by-NRHS solution matrix X.
LDB (input) INTEGER
The leading dimension of the array B. LDB >= max(1,N).
INFO (output) INTEGER
= 0: successful exit
< 0: if INFO = -i, the i-th argument had an illegal value
> 0: if INFO = i, U(i,i) is exactly zero, and the solution has not been computed. The factorization has not been completed unless
i = N.
LAPACK version 3.0 15 June 2000 CGTSV(l)