Sponsored Content
Full Discussion: Array indexing in shell
Top Forums Shell Programming and Scripting Array indexing in shell Post 302392277 by sushmab82 on Thursday 4th of February 2010 12:21:35 AM
Old 02-04-2010
Array indexing in shell

Hi ,
I have 4 array as below

Input:
Code:
servernames=(10.144.0.129 10.144.0.130 10.144.0.131)
subfolder_129=(PSTN_SigtranCamel_03 PSTN_SigtranCamel_04 PSTN_SigtranCamel_05)
subfolder_130=(SigtranCamel_11 SigtranCamel_12 SigtranCamel_13 SigtranCamel_14 SigtranCamel_15)
subfolder_131=(SigtranCamel_21 SigtranCamel_22 SigtranCamel_23 SigtranCamel_24 SigtranCamel_25)

Output:
For each elements of servernames array I need to select all elements of respective subfolder elements. i.e for server name 10.144.0.129 need to select all elemets of subfolder_129 array. and server 10.144.0.131 need to select all elements of subfolder_131.

I have writen below scripts but not working. Could please help me on this?
Code:
foldername=(subfolder_129 subfolder_130 subfolder_131, )
for server in $servernames
do
                j=0
                subfolder=${foldername[$j]}
                index=0
                echo $subfolder
                for x in ${"$subfolder"[$index]}; do
                echo $x

                done
done


Last edited by pludi; 02-04-2010 at 02:03 AM.. Reason: code tags, please...
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

[ask]filtering file to indexing...

dear all, i have file with format like this file_master.txt 20110212|231213|rio|apri|23112|222222 20110212|312311|jaka|dino|31223|543234 20110301|343322|alfan|budi|32131|333311 ... i want filter with output like this index_nm.txt rio|apri jaka|dino ... index_years.txt 20110212... (7 Replies)
Discussion started by: zvtral
7 Replies

2. Shell Programming and Scripting

indexing list of words in a file

Hey all, I'm doing a project currently and want to index words in a webpage. So there would be a file with webpage content and a file with list of words, I want an output file with true and false that would show which word exists in the webpage. example: Webpage content data.html ... (2 Replies)
Discussion started by: Johanni
2 Replies

3. Shell Programming and Scripting

indexing a file

hello guys, I have a file like this: input.dat Push-to-talk No Coonection IP support Support for IP telephony Yes Built-in SIP stack Yes Support via software Yes Microsoft Support for Microsoft Exchange Yes UMA (5 Replies)
Discussion started by: Johanni
5 Replies

4. UNIX for Dummies Questions & Answers

awk, array indexing

cat filename|nawk ' { FS="="; if (!a++ == 0) print $0 } ' can anyone plz explain how does array inexing works,how it is evaluating if (!a++ == 0)?? (2 Replies)
Discussion started by: dreamzalive
2 Replies

5. Shell Programming and Scripting

Split a file using 2-D indexing system

I have a file and want to split it using a 2-D index system for example if the file is p.dat with 6 data sets separated by ">". I want to set nx=3, ny=2. I need to create files p.dat.1.1 p.dat.1.2 p.dat.1.3 p.dat.2.1 p.dat.2.2 p.dat.2.3 I have tried using a single index and want... (3 Replies)
Discussion started by: kristinu
3 Replies

6. Shell Programming and Scripting

How to Assign an shell array to awk array?

Hello All, Can you please help me with the below. #!/bin/bash ARR="No Differences In Stage Between HASH_TOTALS & HASH_TOTALS_COMP For UNINUM:0722075 PROVIDER:5 EXTRACT_DT:30-SEP-12 VER_NUM:1" ARR="No Differences In Stage Between HASH_TOTALS & HASH_TOTALS_COMP For UNINUM:0722075 PROVIDER:5... (14 Replies)
Discussion started by: Ariean
14 Replies

7. Shell Programming and Scripting

Indexing Variable Names

Hi All I think I might have bitten off more than I can chew here and I'm hoping some of you guys with advanced pattern matching skills can help me. What I want to do is index the occurrence of variable names within a library of scripts that I have. Don't ask why, I'm just sad like that... ... (3 Replies)
Discussion started by: bbq
3 Replies

8. UNIX for Dummies Questions & Answers

Single Liner for indexing

Hello, This is pretty simple, I`m looking for a faster and better method than brute force that I`m doing. I have a 20GB file looks like Name1,Var1,Val1 Name1,Var2,Val2 Name2,Var1,Val3 Name2,Var2,Val4 I want 3 files. Nameindex 1 Name1 2 Name2 ... (2 Replies)
Discussion started by: senhia83
2 Replies

9. Shell Programming and Scripting

Pass C shell array to another C shell script(csh) and shell(sh)

Dear Friends, Please help me on this my script name is send.csh In this i have written the statement like this set args = ( city state country price ) I want to pass this array to another c shell called receiver.csh. and i want to use it in this c shell or how to pass to... (2 Replies)
Discussion started by: SA_Palani
2 Replies
RSPARMS(8)						   Linux System Managers Manual 						RSPARMS(8)

NAME
rsparms - Configure the Rose interface. SYNOPSIS
rsparms -nodes add|del address[/mask] port neigh [digis...] rsparms -nodes list rsparms -call <callsign>|none rsparms -version DESCRIPTION
This program is used to manipulate the routing tables of the Rose network layer. To set up a new route to a Rose node in the routing tables you must use the nodes option. All of the parameters are needed to add the node. It is probably best to illustrate with an example: rsparms -nodes add 2080192303 144 F1OAT-11 This creates a new route to a distant node with the address 2080192303 and the packets for that node should be sent on AX.25 port 144 to my immediate neighbour F1OAT-11 without going through any digipeaters. For example to set up the same node but via a digipeater I would use: rsparms -nodes add 2080192303 144 F1OAT-11 F6PRA-9 It is also possible to remove a route to a distant node with the same command except that the "add" is replaced by a "del". The other parameters must also be present. If the node has no other routes then the node will be deleted, and the neighbour node that the connections go via may also be deleted if no other node route uses it. You may list the configured Rose routes using the following syntax: rsparms -nodes list This program may also be used to set up a common AX.25 level 2 callsign that will be used for the ROSE node. By default no special level 2 callsign is set, but setting it will replace any existing level 2 callsign and register another one. Setting the callsign to "none" will remove the level 2 callsign. For example: rsparms -call VK2KTJ-10 would set the callsign used by Rose internode traffic to VK2KTJ-10. OPTIONS
-version Display the version information. FILES
/etc/ax25/axports /etc/ax25/rsports SEE ALSO
call(1), rose(4), axports(5), rsports(5), rsparms(8). AUTHOR
Jonathan Naylor G4KLX <g4klx@g4klx.demon.co.uk> Linux 25 July 1997 RSPARMS(8)
All times are GMT -4. The time now is 04:28 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy