The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Parsing text from file ndnkyd Shell Programming and Scripting 0 04-02-2008 02:42 AM
Need help in parsing text file contents Alecs Shell Programming and Scripting 0 03-30-2008 01:58 PM
Parsing comma delimited text file chengwei Shell Programming and Scripting 5 02-23-2007 05:38 AM
Parsing Lines from a text file sallender Shell Programming and Scripting 3 08-26-2005 12:11 PM
Text parsing question 98_1LE UNIX for Dummies Questions & Answers 3 03-24-2002 11:04 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-26-2008
Djlethal Djlethal is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 2
Text File Parsing

Hey Guys.I am a newbie on Bash Shell Scripting and Perl.And I have a question about file parsing.
I have a log file which contains reports about a communication device.I need to take some of the reports from the log file.Its hard to explain the issue.but shortly I can say that, the reports has a unique report no. and this report number is located at the 2nd or 3rd line and at the end of the report.How can I parse these reports?(I need all of the lines like below.)
It is very important for me.I am waiting for your fast response
Thanking you in advanced

A tiny part of he log file:



INITSX1 2008-02-07 15:45:52 TH

00048 00000000 M147AA03 M1SNSK04
ANOMALY REPORT

ERROR TYPE 1531 CS_MW_COMM_FLT SYSTEM REPORT
-------------------------------------------------------------------------
45:52:07 NA = 0435
ERCLAS SEQ RLVL FMM PROC CS : IP USERDATA
NOTIFY 18 NONE 5005 AA30 15A8:9379 80 A0 12 24 FF FF FF FF 00 00

UNSOLICITED REPORT NO = 00048



INITSX1 2008-02-07 15:46:00 TH
PSW001 0130/000C/0005
SEQ=7734+2007-12-31 00104 00000000 M147AA03 M1SNSK04
SWA-CE LOAD

ACTIVATE-CEOVLD-OBSERV SUCCESSFUL
RESULT PART 0001 -
-------------------------------------------------------------------------
REQUESTED START TIME: = 15:30
REQUESTED STOP TIME : = 15:45
PERIOD: = 00:15

NO PROCESSORS IN OVERLOAD

REPORT FOLLOWS NO = 00104


INITSX1 2008-02-07 15:46:07 TH

00048 00000000 M147AA03 M1SNSK04
ANOMALY REPORT

ERROR TYPE 1531 CS_MW_COMM_FLT SYSTEM REPORT
-------------------------------------------------------------------------
46:07:01 NA = 8402
ERCLAS SEQ RLVL FMM PROC CS : IP USERDATA
NOTIFY 18 NONE 5005 E430 15A8:9379 C0 9D 12 24 FF FF FF FF 00 00

UNSOLICITED REPORT NO = 00048



INITSX1 2008-02-07 15:46:20 TH

00048 00000000 M147AA03 M1SNSK04
ANOMALY REPORT

ERROR TYPE 1530 CS_S12_UX_AU_FLT SYSTEM REPORT
-------------------------------------------------------------------------
46:20:08 NA = C21F
ERCLAS SEQ RLVL FMM PROC CS : IP USERDATA
NOTIFY 10 NONE 5005 AA30 15A8:9379 80 A4 F1 01 2E 02 06 04 00 00

UNSOLICITED REPORT NO = 00048



INITSX1 2008-02-07 15:46:21 TH

00048 00000000 M147AA03 M1SNSK04
ANOMALY REPORT

ERROR TYPE 1531 CS_MW_COMM_FLT SYSTEM REPORT
-------------------------------------------------------------------------
46:21:02 NA = C600
ERCLAS SEQ RLVL FMM PROC CS : IP USERDATA
NOTIFY 18 NONE 5005 0230 15A8:9379 10 A7 12 24 FF FF FF FF 00 00

UNSOLICITED REPORT NO = 00048



INITSX1 2008-02-07 15:46:31 TH

05758 00000000 M147AA03 M1SNSK04
SWA-ORJ-MEAS REPORTING

WARNING
-------------------------------------------------------------------------
FILE READY FOR COPY ON TAPE - START FORMAT COMMAND
CALLTYPE LOG LOG NBR NBR REC
FILE DEV AVAIL USED SIZE
RECS RECS
---------------------------------------------------------------
CELOBS 4553 1032 40 40 2048

UNSOLICITED REPORT NO = 05758


I want to parse the reports like in red.I need to take different reports as well.In the log file there is more than one report for each report types.I mean;some of the reports are taken every 15 minute.Some of them are hourly and log file contains the reports for 2-3 days.And it means that I should have more than one reports for each report types.

The issue is a little bit hard.Any suggestion is welcome for me.I appriciate for your helps.

Last edited by Djlethal; 02-27-2008 at 03:25 AM..
  #2 (permalink)  
Old 02-26-2008
gandolf989 gandolf989 is offline
Registered User
  
 

Join Date: Sep 2006
Location: Pittsburgh
Posts: 20
You would be better off posting a much smaller version of the log file. No way is anyone going to read/comprehend your entire post.

Secondly grep is your friend. You can grep in things that you want, you can also grep -v to exclude things that you don't want. you can use cut to get one part of a line, but it needs to be delimited with something. You can also look at regular expressions which will help you look for any pattern as long as you know the regular expression for that pattern.
  #3 (permalink)  
Old 02-27-2008
Djlethal Djlethal is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 2
thanks for the suggestions.I know grep should be my best friend.But as I told before the pattern that I want to find, is placed on the 3rd line and at the last line.I need the lines between them also.How I can grep these lines?(3rd line till the last line)
Closed Thread

Bookmarks

Tags
regex, regular expressions

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:11 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0