Sponsored Content
Top Forums Shell Programming and Scripting Parsing a log file and creating a report script Post 303002026 by RudiC on Wednesday 16th of August 2017 11:06:55 AM
Old 08-16-2017
How about
Code:
awk -F"\.\.+"   '
BEGIN           {HD = "Device	Manufacturer	Machine Type and Model	FRU Number	Serial Number	Part Number"
                 for (MX=n=split (HD, HDArr, "\t"); n>0; n--)   {SRCH[HDArr[n]]
                                                                 LNG[n] = length(HDArr[n])
                                                                }
                }

/^(SYSTEM|MODEL|PROCESS|NUMBER)/ 

!LEADINDONE &&
!NF             {LEADINDONE    = 1
                 print
                 print HD
                 gsub (/[^\t]/, "-", HD)
                 print HD
                }
!LEADINDONE     {next
                }

NF == 1         {TMPL = RES[HDArr[4]] RES[HDArr[5]] RES[HDArr[6]]
                 if (TMPL != "") for (i=1; i<=MX; i++) printf "%-*s%s", LNG[i], RES[HDArr[i]]?RES[HDArr[i]]:"NA", (i == MX)?ORS:OFS
#                       else     delete CNT[TMPCNT]
                 split ("", RES)
                 split ($0, T, " ")
                 RES[HDArr[1]] = T[1]
                 TMPCNT = T[1]
                 sub (/[0-9]*$/, _, TMPCNT)
                 CNT[TMPCNT]++
                }

NF < 2          {next
                }

                {sub (/^ */, "", $1)
                }

$1 in SRCH      {RES[$1] = $NF
                }

END             {for (i=1; i<=MX; i++) printf "%-*s%s", LNG[i], RES[HDArr[i]]?RES[HDArr[i]]:"NA", (i == MX)?ORS:OFS
                 printf RS
                 for (c in CNT) print "Total", c, ":", CNT[c]
                }

' OFS="\t" file
SYSTEM: nb11cu51
MODEL, TYPE, and SN: IBM,9026-P70,01100699F
PROCESSOR TYPE: PowerPC_RS64-II
NUMBER OF PROCESSORS: 4

Device    Manufacturer    Machine Type and Model    FRU Number    Serial Number    Part Number
------    ------------    ----------------------    ----------    -------------    -----------
rmt0  	EXABYTE     	IBM-20GB              	59H4120   	60171713     	59H4117    
rmt1  	IBM         	03570C11              	NA        	0000000A6844 	NA         
ssa0  	IBM053      	NA                    	 34L5318  	S0237219     	 09L569B   
ssa1  	IBM053      	NA                    	 34L5388  	S0270187     	 09L5695   
rmt1  	IBM         	03570C11              	NA        	0000000A6844 	NA         
hdisk0	IBM         	DNES-309170W          	25L3101     	AJJ55889     	25L1861     
hdisk1	SEAGATE     	DPSS-309170N          	07N3675     	ZD11B560     	07N3721     
pdisk0	IBM         	DRVC09B               	NA        	680BA636SA   	34L8483     
pdisk01	MAC         	DRVC09A               	NA        	680BA636TT   	34L8483     

Total	rmt	:	3
Total	pdisk	:	2
Total	ssa	:	3
Total	pci	:	2
Total	hdisk	:	2
Total	tmscsi	:	2

The total counts are at the end as they are available only then; the reason pci and tmscsi counts are shown is that your input file does NOT stick to a reasonable structure (if you remove the # from the delete CNT line, ssa count will disappear as well...).
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with a shell script for creating a log file

I have a schell script that runs continously on an AIX system. It is actually started from another shell script with the "ksh -x" command and then I just write the output to a log file. This causes the log files to be filled with mostly useless information. I would like to modify this script to... (2 Replies)
Discussion started by: heprox
2 Replies

2. Shell Programming and Scripting

Shell script for parsing 300mb log file..

am relatively new to Shell scripting. I have written a script for parsing a big file. The logic is: Apart from lot of other useless stuffs, there are many occurances of <abc> and corresponding </abc> tags. (All of them are properly closed) My requirement is to find a particular tag (say... (3 Replies)
Discussion started by: gurpreet470
3 Replies

3. Shell Programming and Scripting

Help with script parsing a log file

I have a large log file, which I want to first use grep to get the specific lines then send it to awk to print out the specific column and if the result is zero, don't do anything. What I have so far is: LOGDIR=/usr/local/oracle/Transcription/log ERRDIR=/home/edixftp/errors #I want to be... (3 Replies)
Discussion started by: mevasquez
3 Replies

4. UNIX for Dummies Questions & Answers

Script for parsing details in a log file to a seperate file

Hi Experts, Im a new bee for scripting, I would ned to do the following via linux shell scripting, I have an application which throws a log file, on each action of a particular work with the application, as sson as the action is done, the log file would vanish or stops updating there, the... (2 Replies)
Discussion started by: pingnagan
2 Replies

5. Shell Programming and Scripting

Parsing of file for Report Generation (String parsing and splitting)

Hey guys, I have this file generated by me... i want to create some HTML output from it. The problem is that i am really confused about how do I go about reading the file. The file is in the following format: TID1 Name1 ATime=xx AResult=yyy AExpected=yyy BTime=xx BResult=yyy... (8 Replies)
Discussion started by: umar.shaikh
8 Replies

6. UNIX for Dummies Questions & Answers

Creating a report from csv file.

Hi Gurus, I need your help in transforming the CSV file into some what a report format. My source file looks like below Date,ProdID,TimeID,LevelID 2010-08-31,200,M,1 2010-08-31,201,Q,2 2010-08-31,202,Y,1 2010-08-31,203,M,5 Output required is ... (9 Replies)
Discussion started by: naveen.kuppili
9 Replies

7. Shell Programming and Scripting

Script for Parsing Log File

Working on a script that inputs an IP, parses and outputs to another file. A Sample of the log is as follows: I need the script to be able to input IP and print the data in an output file in the following format or something similar: Thanks for any help you can give me! (8 Replies)
Discussion started by: Winsarc
8 Replies

8. Shell Programming and Scripting

Parsing with Name value pair and creating a normalized file

I have url string as follows and I need to parse the name value pair into fields /rows event_id date time payload 1329130951 20120214 22.30.40... (1 Reply)
Discussion started by: smee
1 Replies

9. Shell Programming and Scripting

Shell script for creating log file and sending mail?

Hi , I am trying to create shell script which will help me to compare file name in two folder. There is a multiple file store in 2 folder.I want to compare that with the name. If all the file are same then send a mail that "all date is same" if not then create one log file which contain... (4 Replies)
Discussion started by: san_dy123
4 Replies

10. Shell Programming and Scripting

Issue with awk script parsing log file

Hello All, I am trying to parse a log file and i got this code from one of the good forum colleagues, However i realised later there is a problem with this awk script, being naive to awk world wanted to see if you guys can help me out. AWK script: awk '$1 ~ "^WRITER_" {p=1;next}... (18 Replies)
Discussion started by: Ariean
18 Replies
zla_lin_berr.f(3)						      LAPACK							 zla_lin_berr.f(3)

NAME
zla_lin_berr.f - SYNOPSIS
Functions/Subroutines subroutine zla_lin_berr (N, NZ, NRHS, RES, AYB, BERR) ZLA_LIN_BERR Function/Subroutine Documentation subroutine zla_lin_berr (integerN, integerNZ, integerNRHS, complex*16, dimension( n, nrhs )RES, double precision, dimension( n, nrhs )AYB, double precision, dimension( nrhs )BERR) ZLA_LIN_BERR Purpose: ZLA_LIN_BERR computes componentwise relative backward error from the formula max(i) ( abs(R(i)) / ( abs(op(A_s))*abs(Y) + abs(B_s) )(i) ) where abs(Z) is the componentwise absolute value of the matrix or vector Z. Parameters: N N is INTEGER The number of linear equations, i.e., the order of the matrix A. N >= 0. NZ NZ is INTEGER We add (NZ+1)*SLAMCH( 'Safe minimum' ) to R(i) in the numerator to guard against spuriously zero residuals. Default value is N. NRHS NRHS is INTEGER The number of right hand sides, i.e., the number of columns of the matrices AYB, RES, and BERR. NRHS >= 0. RES RES is DOUBLE PRECISION array, dimension (N,NRHS) The residual matrix, i.e., the matrix R in the relative backward error formula above. AYB AYB is DOUBLE PRECISION array, dimension (N, NRHS) The denominator in the relative backward error formula above, i.e., the matrix abs(op(A_s))*abs(Y) + abs(B_s). The matrices A, Y, and B are from iterative refinement (see zla_gerfsx_extended.f). BERR BERR is COMPLEX*16 array, dimension (NRHS) The componentwise relative backward error from the formula above. Author: Univ. of Tennessee Univ. of California Berkeley Univ. of Colorado Denver NAG Ltd. Date: November 2011 Definition at line 102 of file zla_lin_berr.f. Author Generated automatically by Doxygen for LAPACK from the source code. Version 3.4.1 Sun May 26 2013 zla_lin_berr.f(3)
All times are GMT -4. The time now is 03:07 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy