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.
Thank you Bartus11 ! that is so impressive - the power of awk in just one line - just to let you know i'm working on AIX and using Korn and your code works a treat. I had an issue at first because the tmplsnr.a wasn't formatted - it had spaces before the db's - i will need to sort that bit out in the future.
LSNR_51526
<spaces>db1
<spaces>db2
LSNR_51527
<spaces>db3
<spaces>db4
<spaces>db5
I have no idea how that works, but it's so cool, can you give me a quick explanation on how that piece of code works. Thanks
The algorithm is pretty simple. It is saving name of the last encountered listener (line starting with LSNR) and prints it when it finds database name.
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)