Displaying log file pattern output in tabular form output


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Displaying log file pattern output in tabular form output
# 8  
Old 02-01-2013
Code:
printf "| %s ",$0;      Print current input record
getline;                Read next input record
s=$0;                   Assign s = entire record
sub(/:.*/,"",s);        Remove everything followed by colon : from s variable value

# 9  
Old 02-01-2013
Thanks bipinajith for detail explination.
I found out the exact reason why it was giving wrong results count.
In the logfile, some of the lines starts with single space and then string either Passed/Failed
something like this input file :
Code:
1). Intercomponents Checking
Passed: All Server are passed.
======================================================================
2). OS version Checking
 Passed: All Server are passed.
======================================================================
3). Component registered and running check
 Failed:VerifyComponent:D01A : Some Component Not RUNNING. ATS 0/1 :
Failed:VerifyComponent:C01A : Some Component Not RUNNING. MTD 0/1 :
======================================================================
4). Verify Server Connection, for ATS/MTD/IDT components
 Failed:ConnectionCheck:D01A : Gateway fail to connect to SAS server!

from the above logfile, we expect result count as
Passed: 2
Failed: 2
but after we run the script, it gives result count as :
Passed: 1
Failed: 1
Is there way we can Trim space before reading the line ?
In meantime, i tried the text color logic from the url which you said. Problem is we can't print the text color inside
the nawk command.
so I thought i will print those count statements after the nawk command but i don't know how to pass the variable
value from nawk command.
Can you please advice on it.
Code:
tmp_p=0
tmp_f=0
tmp_n=0
tmp_c=0
nawk 'BEGIN {
        print "|========================================|"
        print "|        Consolidated Report Status      |"
        print "|========================================|"
        print "|   SI No     CHECKS           STATUS    |"
        print "|========================================|"
 } /^[0-9]/ {
        c++;
        print "|------------------------------------------|"
        printf "| %s ",$0; getline; s=$0; sub(/:.*/,"",s);
        if(s=="Passed") ++p; if(s=="Failed") ++f; if((s!="Passed")&& (s!="Failed")||(s==" ") ) ++n;
        tmp_p=p
        tmp_f=f
        tmp_n=n
       #if(s=="Passed") ++p; if(s=="Failed") ++f; if(s==" ") ++n;
        printf " : %s   |\n", s;
        print "|------------------------------------------|"
 } END {
        print "|========================================|"
        printf "| Total Passed:" p "                    |\n"
        print  "| Total Failed: " f "                   |"
        print "| Total No Result: " n "                 |"
        print "| Total Executed: " c "                      |"
        print "|========================================|"
}' $1
        printf "|\e[1;37;40m========================================|\n"
        printf "| Total \e[1;32;40m Passed: $tmp_p                    |\n"
        printf  "| Total \e[1;31;40m Failed:  $tmp_f                   |\n"
        printf "| Total \e[1;34;40m No Result:  $tmp_n                 |\n"
        printf "| Total \e[1;35;40m Executed:  $c                   |\n"
        printf "|\e[1;37;40m========================================|\n"


Last edited by Optimus81; 02-01-2013 at 11:10 AM.. Reason: need to attach image file for colors
# 10  
Old 02-01-2013
ok, i correct the Trim part by updating this line :
Code:
printf "| %s ",$0; getline; s=$0;sub(" ","", s);sub(/:.*/,"",s);

Now only leftout is how to pass the nawk variable values outside the loop.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script to generate Excel file or to SQL output data to Excel format/tabular format

Hi , i am generating some data by firing sql query with connecting to the database by my solaris box. The below one should be the header line of my excel ,here its coming in separate row. TO_CHAR(C. CURR_EMP_NO ---------- --------------- LST_NM... (6 Replies)
Discussion started by: dani1234
6 Replies

2. Shell Programming and Scripting

Dispaying output in tabular form

hi, I have a script which is dispaying the output as below: Column 3:value1 Column 4:value 4 column 8:value 8 column 9:value 9 column 13:value 13 Column 3:value10 Column 4:value 40 column 8:value 80 column 9:value 90 column 13:value 103 However,I need the output in tabular... (5 Replies)
Discussion started by: Vivekit82
5 Replies

3. Shell Programming and Scripting

Grep command output in tabular format

I have a grep command script which works fine and give the correct results but i wanted the output to be displayed in tabular format ? Is it possible to display the output in tabular format and as well direct them to some file. main script : #!/usr/bin/bash Start_Time=`date '+%m%d%y... (1 Reply)
Discussion started by: Optimus81
1 Replies

4. Shell Programming and Scripting

script to mail monitoring output if required or redirect output to log file

Below script perfectly works, giving below mail output. BUT, I want to make the script mail only if there are any D-Defined/T-Transition/B-Broken State WPARs and also to copy the output generated during monitoring to a temporary log file, which gets cleaned up every week. Need suggestions. ... (4 Replies)
Discussion started by: aix_admin_007
4 Replies

5. Shell Programming and Scripting

Displaying output in the tabular format

Hi I want to display the following input data into the tabular format as shown in the output. Input.txt: Following jobs are in pending state for more than 10 minutes: JOB_ID JOB_SUBMIT_ID MAHAR 784308 PUNJA 109367 Following jobs are running for longer time: JOB_ID... (1 Reply)
Discussion started by: dats
1 Replies

6. UNIX for Dummies Questions & Answers

Put data in tabular form..

Dear Friends, I have a file as under : +++ ME 12-06-13 18:16:20 A RED FEW AND ROW1 1MN FEL AS HI FI BV LR TS HR ES MR * 0 13296 0 120 1 15 KS RR 10 0 +++ ME 12-06-13 18:26:20 A RED FEW AND ROW2 1MN FEL AS... (2 Replies)
Discussion started by: vanand420
2 Replies

7. UNIX for Dummies Questions & Answers

Put data into tabular form

Hi I am having a file which is required to be presented in the under-noted output form. Please suggest. Input: Kapil: apple 4 banana 6 cherry 0 Manoj: apple 13 banana cheery 2 Output: apple banana cherry Kapil: 4 6 0 Manoj: 13 2 Thanks in... (4 Replies)
Discussion started by: vanand420
4 Replies

8. Shell Programming and Scripting

generate tabular output from an input text file in unix shell scripting

Hi, I have the output (as below) which i want it to be in a table. For e.g. space utilization in PSE on path /logs is 0% space utilization in PSE on path /logs/tuxedo/tuxlsp is 16% space utilization in PSE on path /ldvarlsp/lsp/log is 37% space utilization in PSE on path /home is 6%... (7 Replies)
Discussion started by: pkbond
7 Replies

9. Shell Programming and Scripting

Displaying the output in the tabular Format

Hi, I have a file which contains the data in the below format and need to develop a script which will give the output in the tabular format. Could you please advice me. Folder: Workflow: version . Workflow run status: Workflow run error code: Schedule time: Workflow run type: ... (2 Replies)
Discussion started by: kandi.reddy
2 Replies

10. UNIX for Advanced & Expert Users

How to parse through a file and based on condition form another output file

I have one file say CM.txt which contains values like below.Its just a flat file 1000,A,X 1001,B,Y 1002,B,Z ... .. total around 4 million lines of entries will be in that file. Now i need to write another file CM1.txt which should have 1000,1 1001,2 1002,3 .... ... .. Here i... (6 Replies)
Discussion started by: sivasu.india
6 Replies
Login or Register to Ask a Question