Below is the excerpt from my Informatica log file which has 4 blocks of lines (starting with WRITER_1_*_1). Like these my log file will have multiple blocks of same pattern.
From this i need to parse it and get 2 lines from each block as shown below. These 2 lines are related to XMLTgt_FCSLoans25::X_fc_Loan, basically
what i am trying to acheive is number of rows requested only for Loan.
my idea is come up with a script which executes every 15 seconds and get these values (parse 2) and insert into a table from which Java UI program would read and display it as a progress bar in front end for users.
Appreciate your response, please find attached complete log file.
your attached file has nothing to do the data sample quoted in the original posting.
The solution works for the sample data given.
Please provide a representative sample.
As i mentioned i took the excerpt from the log file attached as i don't want to paste the whole content of log file as it looks messy. The attached log file is the one I want to parse, i really appreciate your inputs.
There's no leading WRITER_ in the attached file. That was the key that you mentioned in your original post.
If your attached file IS the file to process, please take samples lines out of this file and show/explain how it should be processed and what output you're after.
This needs to be clarified so that we don't go in circles trying to solve a phantom/moving task.
Apologies for the confusion, interesting though looks like when i downloaded the log (which i attached) from Informatica client tools it is showing like below with timestamp and some extra info.
since i would be executing my script in Linux server, we should choose the vi version of the log output. When i execute your peice of code against the log file in Linux, the output i got is as shown in my previous post, we need to get rid of the word 'this' in the output.
I actually winscpied the log file from Linux server and attached it for your reference please take a look.
awk '
# if the first field starts with WRITER_, set the flag p to 1 and skip to processing the next line
$1 ~ "^WRITER_" {p=1;next}
# if flag p is not 0 AND there's a string X_fc_Loan on current line, increment flag p and skipp to processing the next line
p&&/X_fc_Loan/{p++;next}
# if flag p is equal to 2 (already saw WRITER_ and X_fv_Loan lines) AND NumberOfFields (NF) is greater than 6 AND the 6-th field contains ONLY numbers (the last 2 conditions filter out non-complete lines AND lines where the 6-th field is not numeric), print the 6-th field and reset flag p to 0.
# Example of the invalid lines:
#WRT_8036 Target: XMLTgt_FCSLoans25::X_fc_Loan (Instance Name: [XMLTgt_FCSLOANS_Ver25_Norm])
#WRT_8044 No data loaded for this target
p==2 && NF>=6 && $6 !~/[^0-9]/{print $6;p=0}
' s_GenerateXMLDataFile.txt
not that we have it all squared away, could I get a discount for a new Bimmer?
Hello,
For example if the log file has below lines, it is printing the value beneath the X_fc_Customer when X_fc_Loan has "WRT_8044 No data loaded for this target" which it shouldn't have printed, how do i restrict to print only the numbers below X_fc_Loan??
FYI...I modified your command little bit as shown below (print $6 instead of print $12)