Sponsored Content
Top Forums Shell Programming and Scripting Manipulating a list into a two-dimensional array Post 302740685 by mingy10 on Thursday 6th of December 2012 03:04:17 PM
Old 12-06-2012
Manipulating a list into a two-dimensional array

hi,
total newbie to shell scripting and wondering if some of you guru's can give me a hand on a problem I'm trying to solve.

The tmplsnr.a file contains

Code:
LSNR_51526
db1
db2
LSNR_51527
db3
db4
db5

Summary - depending on which db is set, the script will start the relevant listener (LSNR_). e.g if db5 is set then the script will start the LSNR_51527 listener.

I was thinking the best way maybe to put this information into an array and then search the array.

I want to read the above file into a two dimensional array and the array to looks like this so that I can search the corresponding LSNR for the db.
Code:
LSNR_51526,db1
LSNR_51526,db2
LSNR_51527,db3
LSNR_51527,db4
LSNR_51527,db5

How would I search the array for the listener (LSNR_51527) which relates to db5 ?

Would this method work or have I over complicated things or is there a much simpler method in korn scripting.

I would appreciate any feedback or help

Many Thanks in Advance

Last edited by mingy10; 12-06-2012 at 04:13 PM.. Reason: Please wrap data and sripts with CodeTags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Reference two dimensional array in Perl sub

I am trying to reference a two dimensional array in a subroutine and can't seem to figure this one out in Perl. Does anybody know? Please enlighten me. #!/usr/bin/perl -w use constant DIM => 4; sub Shift_elements_right{ my (@Input, @Output) = @_; for ($i = 0 ; $i <= DIM ;... (5 Replies)
Discussion started by: photon
5 Replies

2. Shell Programming and Scripting

Help for record (2 dimensional array.)

I am going to develop a address book using the shell scripting commands without sed, awk, .... I am thinking to apply the concept of 2 dimenstional array. Can I create a two dimensional array for the insertion/updation/deletion of record in unix. If yes then tell me plz or recommend me some... (1 Reply)
Discussion started by: murtaza
1 Replies

3. Shell Programming and Scripting

Manipulating Pick multi dimensional data with awk.

Hi. I am reasonably new to awk, but have done quite a lot of unix scripting in the past. I have resolved the issues below with unix scripting but it runs like a dog. Moved to awk for speed and functionality but running up a big learning curve in a hurry, so hope there is some help here. I... (6 Replies)
Discussion started by: mike.strategis
6 Replies

4. Shell Programming and Scripting

2 dimensional array in unix

I am trying to implementing two dimensinal array in ksh script.Would you pls help me out. I have a large size of file, File contains looks like ID SID VLAUE1 VALUE2 TOTALVALUE 1 a1 01 02 03 1 b1 02 05 07 ... (2 Replies)
Discussion started by: pritish.sas
2 Replies

5. Shell Programming and Scripting

PHP: Search Multi-Dimensional(nested) array and export values of currenly worked on array.

Hi All, I'm writing a nagios check that will see if our ldap servers are in sync... I got the status data into a nested array, I would like to search key of each array and if "OK" is NOT present, echo other key=>values in the current array to a variable so...eg...let take the single array... (1 Reply)
Discussion started by: zeekblack
1 Replies

6. Programming

C++ Segmentation error with bi-dimensional array

Hello, I'm experiencing a weird seg fault at run time when initializing a bi-dimensional array and initializing a class. Please see below code and comments describing the error and the instances when it occurs and when it does not occur. Compiled with g++ segf.cpp -o segf output On... (5 Replies)
Discussion started by: nmset
5 Replies

7. Programming

Return two dimensional array in c++

I am writing matrix multiplication and trying to return a two dimensional array from a function but I keep getting errors. Can someone please help me? here is my code (it is just the skeleton of my program): void main () { ... int *matmultiply (int, int, int, int , int , int ) ... } ... (4 Replies)
Discussion started by: saboture88
4 Replies

8. Shell Programming and Scripting

Storing two dimensional array for postprocessing

Hi Community, Would love to get some quick help on below requirement. I am trying to process mpstat output from multiple blades of my server I would like to assign this the output to an array and then use it for post processing. How can I use a two dimensional array and assign these value ... (23 Replies)
Discussion started by: sshark
23 Replies

9. Shell Programming and Scripting

Multi Dimensional array

I have an array of names. Each one of the name, has a number represented to it. For example A has an ID 8, B has an ID 2. What I am after is a for loop that when the array is in position 1, a particular variable is set to the value of position 1 in array 2 declare -a arr=("A" "B" "C"... (6 Replies)
Discussion started by: nms
6 Replies

10. Shell Programming and Scripting

Assign Two Dimensional Array In Bash At Once

Hi, I have a 10*10 two dimensional array. How do I assign value to all it's 100 elements at once? I don't want to open two for loops and assign one by one. Thanks, Shuri (1 Reply)
Discussion started by: shurimano
1 Replies
DB5.1_DUMP(1)						      General Commands Manual						     DB5.1_DUMP(1)

NAME
db5.1_dump - Write database to flat-text format SYNOPSIS
db5.1_dump [-klNpRrV] [-d ahr] [-f output] [-h home] [-P password] [-s database] file DESCRIPTION
The db5.1_dump utility reads the database file file and writes it to the standard output using a portable flat-text format understood by the db5.1_load utility. The file argument must be a file produced using the Berkeley DB library functions. OPTIONS
-d Dump the specified database in a format helpful for debugging the Berkeley DB library routines. a Display all information. h Display only page headers. r Do not display the free-list or pages on the free list. This mode is used by the recovery tests. The output format of the -d option is not standard and may change, without notice, between releases of the Berkeley DB library. -f Write to the specified file instead of to the standard output. -h Specify a home directory for the database environment; by default, the current working directory is used. -k Dump record numbers from Queue and Recno databases as keys. -l List the databases stored in the file. -N Do not acquire shared region mutexes while running. Other problems, such as potentially fatal errors in Berkeley DB, will be ignored as well. This option is intended only for debugging errors, and should not be used under any other circumstances. -P Specify an environment password. Although Berkeley DB utilities overwrite password strings as soon as possible, be aware there may be a window of vulnerability on systems where unprivileged users can see command-line arguments or where utilities are not able to overwrite the memory containing the command-line arguments. -p If characters in either the key or data items are printing characters (as defined by isprint(3)), use printing characters in file to represent them. This option permits users to use standard text editors and tools to modify the contents of databases. Note: different systems may have different notions about what characters are considered printing characters, and databases dumped in this manner may be less portable to external systems. -R Aggressively salvage data from a possibly corrupt file. The -R flag differs from the -r option in that it will return all possible data from the file at the risk of also returning already deleted or otherwise nonsensical items. Data dumped in this fashion will almost certainly have to be edited by hand or other means before the data is ready for reload into another database -r Salvage data from a possibly corrupt file. When used on a uncorrupted database, this option should return equivalent data to a nor- mal dump, but most likely in a different order. -s Specify a single database to dump. If no database is specified, all databases in the database file are dumped. -V Write the library version number to the standard output, and exit. Dumping and reloading Hash databases that use user-defined hash functions will result in new databases that use the default hash function. Although using the default hash function may not be optimal for the new database, it will continue to work correctly. Dumping and reloading Btree databases that use user-defined prefix or comparison functions will result in new databases that use the default prefix and comparison functions. In this case, it is quite likely that the database will be damaged beyond repair permitting nei- ther record storage or retrieval. The only available workaround for either case is to modify the sources for the db5.1_load utility to load the database using the correct hash, prefix, and comparison functions. The db5.1_dump utility output format is documented in the Dump Output Formats section of the Berkeley DB Reference Guide. The db5.1_dump utility may be used with a Berkeley DB environment (as described for the -h option, the environment variable DB_HOME, or because the utility was run in a directory containing a Berkeley DB environment). In order to avoid environment corruption when using a Berkeley DB environment, db5.1_dump should always be given the chance to detach from the environment and exit gracefully. To cause db5.1_dump to release all environment resources and exit cleanly, send it an interrupt signal (SIGINT). Even when using a Berkeley DB database environment, the db5.1_dump utility does not use any kind of database locking if it is invoked with the -d, -R, or -r arguments. If used with one of these arguments, the db5.1_dump utility may only be safely run on databases that are not being modified by any other process; otherwise, the output may be corrupt. The db5.1_dump utility exits 0 on success, and >0 if an error occurs. ENVIRONMENT
DB_HOME If the -h option is not specified and the environment variable DB_HOME is set, it is used as the path of the database home, as described in DB_ENV->open. AUTHORS
Sleepycat Software, Inc. This manual page was created based on the HTML documentation for db_dump from Sleepycat, by Thijs Kinkhorst <thijs@kinkhorst.com>, for the Debian system (but may be used by others). 28 January 2005 DB5.1_DUMP(1)
All times are GMT -4. The time now is 09:44 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy