Hi! I have a file which I want to search daily for any line that contains the work 'Reason' and I want to take that line and put the data in a certain format using awk or nawk....I do not have gawk on my machine so it would have to be awk or nawk, or sed would work as well. Here are some examples of the input lines:
-07/07@04:03:34 - 10.7.23.144 : DIAG 3x3b: Reason: code 0x60, Sent by kernel-
-07/07@04:04:14 - 10.37.42.194 : DIAG 3x3b: Reason: code 0x60, Sent by kernel-
-07/07@06:50:04 - 10.7.14.854 : DIAG 0x72: Reason: FATAL MEMORY ERROR - guard band corrupt (addr:0x70e6190 size:32 owner:75(TblMgr Main)) at _mem_DeletePointer line 1737-
-07/07@08:35:28 - 10.7.62.820 : DIAG 0x72: Reason: OCP initiated reset...Rebooting from Delay Dial Option-
-07/07@10:33:14 - 10.7.23.167 : DIAG 0x72: Reason: PASSTHRU RESET MESSAGE-
-07/07@10:34:28 - 10.7.42.621 : DIAG 0x72: Reason: OCP initiated reset...Rebooting from Delay Dial Option-
-07/07@11:19:33 - 10.5.26.704 : DIAG 3x3b: Reason: code 0x11, Unmapped address, fault address: 0x00000925-
-07/07@11:19:33 - 10.7.26.704 : DIAG 3x3b: Reason: code 0x11, Unmapped address, fault address: 0x00000925-
-07/07@11:19:45 - 10.7.24.277 : DIAG 0x72: Reason: OCP initiated reset...Rebooting from Delay Dial Option-
-07/07@15:43:47 - 10.7.25.474 : DIAG 0x72: Reason: PASSTHRU RESET MESSAGE-
-07/07@15:56:38 - 10.7.65.77 : DIAG 0x72: Reason: Error! line 548 of dacct_ExitLoadClImage() in dacctrail/dacct.c-
-07/07@17:13:40 - 10.7.23.342 : DIAG 0x72: Reason: OCP initiated reset...IMAGE upgrade complete!-
-07/07@17:47:57 - 10.5.44.351 : DIAG 0x72: Reason: ERROR: dk_Reset called.-
The output I would like is to eliminate any lines that contain "OCP" or "PASSTHRU RESET" and put everything in the following format:
Date/Time,Location,Shelf,IP,Reason,Log Filename
07/07@04:03:34,-,-,10.7.23.144,DIAG 3x3b: Reason: code 0x60, Sent by kernel,$DATE/10.7.23.144
07/07@04:04:14,-,-,10.37.42.194,DIAG 3x3b: Reason: code 0x60, Sent by kernel,$DATE/10.37.42.194
07/07@06:50:04,-,-,10.7.14.854,DIAG 0x72: Reason: FATAL MEMORY ERROR - guard band corrupt (addr:0x70e6190 size:32 owner:75(TblMgr Main)) at _mem_DeletePointer line 1737,$DATE/10.7.14.854
07/07@11:19:33,-,-,10.5.26.704,DIAG 3x3b: Reason: code 0x11- Unmapped address- fault address: 0x00000925,$DATE/10.5.26.704
07/07@11:19:33,-,-,10.7.26.704,DIAG 3x3b: Reason: code 0x11, Unmapped address, fault address: 0x00000925,$DATE/10.7.65.77
07/07@15:56:38,-,-,10.7.65.77,DIAG 0x72: Reason: Error! line 548 of dacct_ExitLoadClImage() in dacctrail/dacct.c,$DATE/10.7.65.77
07/07@17:47:57,-,-,10.5.44.351,DIAG 0x72: Reason: ERROR: dk_Reset called,$DATE/10.5.44.351
The problem I am having is I want to be able to put this data into an Excel file and so I need to remove any commas that are in the 'Reason' column or else it puts them into seperate cells. Aslo, at the end where it says $DATE I want it to display a date variable that I have and then the IP address.