printing arrays

Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers printing arrays
# 1  
Old 07-09-2001
Question printing arrays

Suppose I assign these variables:
let col=n/2
let table$row[$col]=val

I want to print the last variable. How do I do that? I have tried:
echo ${table$row[$col]}
This is the error message:
ksh: ${table$row[$col]}: bad substitution
# 2  
Old 07-09-2001
Lightbulb Nevermind

I fixed that problem
# 3  
Old 07-09-2001
When you fix problems or find solutions to problems that you post, PLEASE post the solutions and fixes. This adds to the knowledge base and helps everyone greatly! THANK YOU.
# 4  
Old 07-09-2001
CPU & Memory RE: solution

Disregard the below solution. It does not work. I am still working on this problem. Any ideas??

The array variable name includes "table" and the value of another variable, $row (thus, table$row). This variable is an array with $col number of elements.

The erroneous command:

echo ${table$row[$col]}

The problem:
The shell attempts substitution, which is not the desired outcome. I want to echo the value of the array element.

The solution:

echo $(table$row[$col])

This command prints to the terminal the value of the $col element in the table$row variable.

Smilie Smilie Smilie

Last edited by morkfard; 07-09-2001 at 08:59 PM..
# 5  
Old 07-10-2001
MySQL hint...

hi folks.

i hav a hint for you:

to display the last fieldnumber type:

echo ${#myarray} # shows number of fields

cheers, alex...

# 6  
Old 07-10-2001
Re: hint...

Thanks for the idea, Alex. Do you know how to echo a variable within a variable?
# 7  
Old 07-10-2001


variable within a variable? i am not shure what you mean (my english si not so good, i am from vienna/austria, living in germany now), but look at this:



echo $VAR2

this is for kornshell!

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Printing, SYSPRINTER, IP printing

Dear readers, We have a printer problem with a UNIX system. The OS is Unix IRIX 6.5 We have connected a printerto the system. If we then make a test print everything goes well . (IP printing) But if we make a print from the "orrga,i"program. Then we see all the printouts stuck within the... (3 Replies)
Discussion started by: SergevdH
3 Replies

2. UNIX for Dummies Questions & Answers


Am using bash For eg: Suppose i have a array arr=(1 2 3 4 5 6 7 8 9 10 11 12) suppose i give input 5 to a script and script should able to print values greater than or equal to 5 like below: Input: 5 output: 5,6,7,8,9,10,11,12 (7 Replies)
Discussion started by: manid
7 Replies

3. Programming

Arrays in C++

I've noticed something interesting in C++ programming. I've always done tricky stuff with pointers and references to have functions deal with arrays. Doing exercises again out of a C++ book has shown me an easier way, I didn't even know was there. It's weird to me. When dealing with arrays, it... (4 Replies)
Discussion started by: John Tate
4 Replies

4. UNIX for Dummies Questions & Answers

Sco Unix printing : jobs hangs in queue - printing via lp versus hpnpf

Hi, We have a Unix 3.2v5.0.5. I installed a printer via scoadmin, HP network printer manager with network peripheral name (hostname and ipadres are in /etc/hosts). This is the configuration file : Code: root@sco1 # cat configurationBanner: on:AlwaysContent types: simpleDevice:... (0 Replies)
Discussion started by: haezeban
0 Replies

5. Windows & DOS: Issues & Discussions

Linux to Windows Printing: PDF starts printing from middle of page.

We are using Red Hat. We have a issue like this: We want to print from Linux, to a printer attached to a Windows machine. What we want to print is a PDF. It prints, but the printing starts from the middle of the page. In the report, there is no space at the top but still printing starts from the... (5 Replies)
Discussion started by: rohan69
5 Replies

6. Programming

question about int arrays and file pointer arrays

if i declare both but don't input any variables what values will the int array and file pointer array have on default, and if i want to reset any of the elements of both arrays to default, should i just set it to 0 or NULL or what? (1 Reply)
Discussion started by: omega666
1 Replies

7. Web Development

PHP arrays in arrays

PHP question... I have an SQL query that's pulled back user IDs as a set of columns. Rather than IDs, I want to use their names. So I have an array of columns $col with values 1,7,3,12 etc and I've got an array $person with values "Fred", "Bert", "Tom" etc So what I want to do is display the... (3 Replies)
Discussion started by: JerryHone
3 Replies

8. Shell Programming and Scripting

arrays not printing properly in bash

hi guys, i wrote this script and it takes some fields from a file and puts it into three different arrays. The first array works just fine but when I try to use the second array (ARRAY1) all i get is a blank value on the screen.. this works fine..i get ARRAY value on the screen just fine ... (1 Reply)
Discussion started by: npatwardhan
1 Replies

9. Shell Programming and Scripting


Dear all, How can i unset arrays. I mean all the subscripts including the array after using them. Could you direct me to some links of array memory handling in the korn shell. Thanks (2 Replies)
Discussion started by: earlysame55
2 Replies

10. UNIX for Advanced & Expert Users

Printing Problems in unix ... ( Bar-cdoe - Ip Printing)

Hi guys ... i need ur help with some printing problem in unix ... first prob. : i wanna print from my NCR unix to an Win NT , Ip based printing server ( HP JetDirect ) . My issue , is it possible to print directly to an Ip address from unix ? How do i make it work to get any results ?... (3 Replies)
Discussion started by: QuickSilver
3 Replies
Login or Register to Ask a Question