I think you are making things much more complicated than they need to be. Here's an example that prints instance name, production host, and backup host and also indicates if there is no backup host.
Running it on your sample data yields this:
May not be exactly what you want, but should give you an idea of how you can organise your code to give you both.
---------- Post updated at 22:14 ---------- Previous update was at 22:02 ----------
In a nutshell, I need to work out how to return the last matching pattern from an awk //,// search. I can bring back the first, but am unsure how to obtain the last, and a simple tail won't work as the match could be over multiple lines.
Secondly I would like some way of pattern matching, a... (10 Replies)
Dear Team,
How do we match two patterns on the same line using awk?Are there any logical operators which i could use in awk like awk '\gokul && chennai\' <filename>
Eg:
Input file:
gokul,10/11/1986,coimbatore.
gokul,10/11/1986,bangalore.
gokul,12/04/2008,chennai.... (2 Replies)
Hello all,
I am trying to sort thru a database and print all the customers whose first names are only four characters. I just want to pull the first name only from the database.
the database records appear like this in file:
Mike Harrington:(510) 548-1278:250:100:175; first is name Mike... (4 Replies)
I'm newbie with AWK. What I'm trying to do is matching file1 and file2 into a file3 with records listed in columns with pipe as delimiter.
The thing is the file1 has thousands of records while file2 has very few. But I want the file3 to show all records in file1 and with data from file2 to be... (2 Replies)
I have a file that looks something like this with lots of text before and after.
Distance method: Sum of squared size difference (RST)
</data> <pairwiseDifferenceMatrix time="02/08/11 at 13:08:27">
1 2
1 448.82151 507.94231
2 ... (7 Replies)
Hello,
I am working with google ngram data set which is of size 100s of gb. Before using it with Java, I wanted to filter it out using shell script.
Here is a sample line in the file:
2.55 1.57 1992 10 20 30
The first two fields (2.55 and 1.57) are... (3 Replies)
Hello,
I have two files as follow:
AFFY_ID RS_ID CHROMOSOME POS_START POS_END ALLELE1 ALLELE2
SNP_A-1780283 rs17011450 chr4 127630275 127630276 C T
SNP_A-1780285 rs6919430 chr6 90919464 90919465 A C
SNP_A-1780286 --- chr7 104281409 104281410 A G
SNP_A-1780301 rs2342723 chr16 5748790... (1 Reply)
Hi, I have text file:
Name: xyz
Gender: M
Address: "120_B_C; ksilskdj; lsudlfw"
Zip: 20392
Name: KLM
Gender: F
Address: "65_D_F; wnmlsi;lsuod;,...."
Zip:90233I want to insert 2 new lines before the 'Address: ' line deriving value from this Address line value
The Address value in quotes... (1 Reply)
Hello,
I have two files file 1 and file 2 each having result of a query on certain database tables and need to compare for Col1 in file1 with Col3 in file2, compare Col2 with Col4 and output the value of Col1 from File1 which is a) not present in Col3 of File2 b) value of Col2 is different from... (2 Replies)
Using the awk below I am able to combine all the matching dates in $1, but I can not seem to remove the non-matching from the file. Thank you :).
file
20161109104500.0+0000,x,5631
20161109104500.0+0000,y,2
20161109104500.0+0000,z,2
20161109104500.0+0000,a,4117... (3 Replies)