trying to store variables in an array


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers trying to store variables in an array
# 1  
Old 07-20-2009
trying to store variables in an array

im looping through an array setting three variables each time (one of the variables gives me the position in the array and is incremented each loop)

im trying to then set the variables to that position in the array without much luck. any ideas?

anArray[$ps]=`$VAR1+$VAR2+"("$pos")"`
# 2  
Old 07-21-2009
Your question is not clear.
From wht I understand,this is what you are looking for:
Code:
anArray[$ps]=${VAR1}${VAR2}"("$pos")"

you dont need + to concatenate in Unix.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Store output in variables instead of files

Hi All, I have written a (bash) function which generates multiple files say file1 file2 file3 now I want to reduce the generation of these three files i.e. store the output of three files in variables, and generate the same results, in-order to avoid multiple creation of files how is that... (7 Replies)
Discussion started by: sam@sam
7 Replies

2. Shell Programming and Scripting

Store in a 2 dimensional array - Perl

Hey guyz. Here is my sample input file following by first part of my code: * A B C D E reg1 1 0 1 1 0 reg2 0 1 0 0 1 reg3 1 0 0 1 0 reg4 0 0 1 0 1 reg5 1 1 0 0 1 use strict; use warnings; open (IN, "test_input.txt") or die ("Can't open file.txt: $!\n"); my $line = <IN>; ... (2 Replies)
Discussion started by: @man
2 Replies

3. Shell Programming and Scripting

Store value in array with awk

Hi everybody I wanna store some values that r in a .txt file in some arrays for example I have: 32782 28 32783 02 32784 01 32785 29 32786 25 32787 25 32788 00 32789 25 32790 02 32791 29 32792 23 32793 01 32794 28 and I need to save the first... (4 Replies)
Discussion started by: Behrouzx77
4 Replies

4. Shell Programming and Scripting

Can -v option in awk be used to store an array of variables?

I want to pass an array of variables to be inserted by awk in the 2nd column of a file. Empl No. Employee Age 1000000 22 1100000 24 1200000 26 Now, I want to pass an array having three different ages which need to replace the... (7 Replies)
Discussion started by: Nishi_Licious
7 Replies

5. Shell Programming and Scripting

saving all input name and store them as variables

Hi I want to write a script such that when executed, it will store all input as different variable, for eg ./store.sh name1 name2 name3 name4 will result in $1=name1 $2=name2 $3=name3 etc How do I do that? Thanks. (1 Reply)
Discussion started by: piynik
1 Replies

6. Shell Programming and Scripting

Store all the passed arguments in an array and display the array

Hi I want to write a script which store all the parameters passed to the script into an array. Once it is stored I want scan through the array and and delete those files for last month present inside the directory. The files in directory is appneded with YYYY_MM_DD. I want to know how can I... (3 Replies)
Discussion started by: dgmm
3 Replies

7. Shell Programming and Scripting

store multiple variables in one go

Guys anyone know how i can store fields into multiple variables in one go? I'm wanting to grab the disk id's from format into disk1 and disk2 Below is what i want to work but i know it doesnt :- : | format | awk '/^(\ +)/ {print $2}' | read disk1 disk2 The below does work...but i don't... (5 Replies)
Discussion started by: lavascript
5 Replies

8. Shell Programming and Scripting

Store values in an Array

Hi all. Well, I have the next code: I need to make an array with the values I have in the bucle, but just don't get it... Question is, how can I store in an array that values, and how can I display them with echo? (8 Replies)
Discussion started by: crcbad
8 Replies

9. Shell Programming and Scripting

How to store contents of a command in array of variables in shell script?

I want to store contents of command dir in array of variables For eg: dir contents are command d2 demovi~ file inven java new untitled folder d1 demovi er1 filename inven~ myfiles ubuntu desktop xmms ----------------------------------- I... (3 Replies)
Discussion started by: netresearch
3 Replies

10. UNIX for Dummies Questions & Answers

How to store the values in a file into an array

Hi, I do have a file and the contents are as follws: 10 20 30 40 50 Now I want to store those values into an array. How can be done this ?? (3 Replies)
Discussion started by: risshanth
3 Replies
Login or Register to Ask a Question