Re: Is there array of array in bash?



On Tue, 01 Jul 2008 19:55:53 -0300, PengYu.UT@xxxxxxxxx <PengYu.UT@xxxxxxxxx> wrote:

Hi,

I'm trying to use an array of array in bash in the following script.
It is not working. Is there a way to make it work?

Thanks,
Peng

$cat ./array_of_array.sh
#!/bin/bash

coordinates=((0 0) (1 1))

for c in $coordinates[*];
do
echo $c
done

$ ./array_of_array.sh
./array_of_array.sh: line 3: syntax error near unexpected token `('
./array_of_array.sh: line 3: `coordinates=((0 0) (1 1))'
[*]



$ coordinates=(0 1 2 3)
$ for c in ${coordinates[*]};do echo $c;done
0
1
2
3
$
.



Relevant Pages

  • Re: Referencing Korn Shell Array Names as a Variable
    ... Your idea worked for displaying the output from the command. ... $ echo $ ... # Attempt to use variable array name and index to reference array value ... The issue is with this line of the script ...
    (comp.unix.shell)
  • Re: array problem: space between words
    ... last_arr_member# FUNCTION to echo the amount of members an array contains ... can be used to append an element to the array. ... Removing my 'echo', and your 'eval', this is the quickest way for bash I can think of by now. ... Yes, I use command substitution in the calling functions, to do things like reverse iterating and array. ...
    (comp.unix.shell)
  • Re: Logon script - function array and select case not working
    ... this all works well, except, the function i am using for the rules in the control script causes alot of querrys to AD. as there are alot of groups. ... objTSout.writeline retrv ... So if you think that this will assign an array value to the variable, how do you think the case select statement is going go compare this array value with the literal string values such as "group name here"? ... However, by not assigning ANY value to checkgrp in the function, you are guaranteeing that, should the function ever exit, it will return no information. ...
    (microsoft.public.scripting.vbscript)
  • Re: Perl: Subroutines and use of the "GD::Graph::bars;" Module
    ... I have been looking at the script once again, I could not really get your suggestion to work, but I have been doing some new changes thought. ... @array = sort @array; ... sub verbose { ... Global symbol "$title" requires explicit package name at ./bars.pl line 53. ...
    (perl.beginners)
  • Re: string retrieval issue
    ... Chicago Bears|NFC North ... not writing the third element back to the array). ... You didn't include it in your script. ... Fear is the mind-killer. ...
    (comp.lang.perl.misc)