Sponsored Content
Full Discussion: Nested Arrays
Top Forums Shell Programming and Scripting Nested Arrays Post 69066 by guysporty on Monday 11th of April 2005 08:01:35 AM
Old 04-11-2005
Nested Arrays

Hi,

I'm trying to implement nested arrays in ksh.

i've the follwing arrays
SRV=\
"SRV1 "\
"SRV2 "

SRV1=\
"MD11 "\
"MD12 "

SRV2=\
"MD21 "\
"MD22 "

MD11=\
"ABC "

MD12=\
"EFG "

MD21=\
"XYZ "

MD22=\
"PQR "

for i in $SRV
do
echo $i

for j in $i
do
echo $j
done
done


The output of this is
SRV1
SRV1

What i need is the output should be
SRV1
MD11


What its doing is substituting the value of $i in the for loop where as what is actually required is $$i. however this syntax is not acceptable

Can anyone help me out on this as to how to achieve it.

Thanks.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Nested Loop to Echo Multiple Arrays

I have three arrays which hold three elements each. I have a fourth array which contains the names of those three arrays. I'm having difficulty creating a nested loop that can loop through each array and echo their values. script #!/bin/ksh # array of locations (usa, london, australia)... (1 Reply)
Discussion started by: yongho
1 Replies

2. Shell Programming and Scripting

nested variables

Is there any way to do variable nesting using sh? For example: example_1="a test string" example_2="another test" example_3="etc..." i=2 echo ${example_$i} The shell reports: sh: ${example_$i}: bad substitution If not, maybe someone could suggest another method. Thanks in... (3 Replies)
Discussion started by: kevinl33
3 Replies

3. 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

4. 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

5. Programming

Help nested sql

Hi, I bought a module called "Price comparison listing" for Prestashop that was supposed to help me push product listing to kelkoo. Unfortunately it doesnt work and the developers don't fix, and they don't refund.... I have reported this to prestashop, but I need a solution.. Be careful buying... (1 Reply)
Discussion started by: joje47
1 Replies

6. UNIX for Dummies Questions & Answers

Nested If in Unix

Hi!! LookVar=`find . -name "${input}" | wc -w` if then cd $input rm -f * ftp -n -i $HostName << EOF quote USER $User quote PASS $Password cd $Path SoLookVar=`find . -name "${input}" | wc -w` echo $SoLookVar if then cd $input mget ./* bye EOF chmod 775 ./* (12 Replies)
Discussion started by: Afsana
12 Replies

7. Shell Programming and Scripting

Nested if in KSH

Trying to clean up the last little thing in this script which is that the mv always performs no matter whether it is needed or not. It doesn't cause any bugs just prints an unsightly "can't mv source and dest are the same". Obviously I want to get rid of it but having issues getting the... (4 Replies)
Discussion started by: Calbrenar
4 Replies

8. Shell Programming and Scripting

Nested case

Hi there, I have nested case in my script. I am asking user, want to continue? if user press y/Y then my inner case should continue, rather than that my code start from beginning. I would like to continue my inner case until user press n or N. Is any one tell me how can I do? Thanking You,... (2 Replies)
Discussion started by: kasparov
2 Replies

9. Shell Programming and Scripting

Nested if loop

Hi Team, I just want to check whether my nested if loop used is correct or not. if ] if ] export1 else export2 fi else if ] export3 else export4 fi fi Thanks Shiva (5 Replies)
Discussion started by: shivashankar_S
5 Replies

10. Shell Programming and Scripting

Nested if else

Hi, i m trying to create script which logic is like below. if ; then x=`cat /tmp/testoutput.log | grep STOP | wc -l` y=`cat /tmp/testoutput.log | grep RUN | wc -l` if ; then echo "process stop" if ; then echo "process running " else echo "file not found" fi ----------------... (2 Replies)
Discussion started by: tapia
2 Replies
BBDB-SRV.PL(1)						      General Commands Manual						    BBDB-SRV.PL(1)

NAME
bbdb-srv - Converts Mail-Headers to an Emacs-Lisp String. SYNOPSIS
echo Some Headers | bbdb-srv DESCRIPTION
This script reads a block of message headers on stdin, and converts them to an emacs-lisp string (quoting all dangerous characters) and then uses the `gnudoit' program to cause a running Emacs process to invoke the `bbdb-srv' function with that string. This has the effect of causing the running Emacs to display the BBDB record corresponding to these headers. See the Emacs side of things in bbdb-srv.el for more info. A trivial application of this is the shell command: echo 'From: Jamie Zawinski <jwz@netscape.com>' | bbdb-srv.perl which will cause the corresponding record to be displayed. A more interesting application of this is: setenv NS_MSG_DISPLAY_HOOK bbdb-srv.perl which will hook BBDB up to Mozilla (Unix Netscape Mail and Netscape News versions 3.0b2 and later only.) This manual page was written for the Debian distribution because the original program does not have a manual page. Instead, it has docu- mentation in the GNU Info format; see below. SEE ALSO
bbdb-areacode-split(1), bbdb-unlazy-lock(1). bbdb-srv(1). The bbdb is fully documented by The insidious Big Brother Database for mail and news, available via the Infonode bbdb AUTHOR
This manual page was written by Joerg Jaspert (JJ) <joerg@goliathbbs.dnsalias.net>, for the Debian GNU/Linux system (but may be used by others). March 31, 2002 BBDB-SRV.PL(1)
All times are GMT -4. The time now is 05:15 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy