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
Dealing with spaces in file names in a shell script same1290 Shell Programming and Scripting 5 08-13-2008 12:01 AM
xlC compilation error when dealing with operator overloading luop0812 AIX 1 04-09-2008 05:09 PM
perl: When dealing with files that do not exist joeyg Shell Programming and Scripting 2 02-20-2008 05:09 PM
Help in dealing with arra jojan Shell Programming and Scripting 5 08-28-2007 03:14 PM
tsch script problem (dealing with sed) csnewbie84 Shell Programming and Scripting 10 05-02-2007 11:51 PM

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 01-19-2009
charudpss charudpss is offline
Registered User
  
 

Join Date: Jan 2009
Posts: 9
Dealing with log files

Hi ,
My requirement is that i need to search for a number of strings in a log file and print them with line numbers.The search should be date wise.
The sample log file is :

Jan 17 02:45:34 srim6165 MQSIv500[22581]: [ID 702911 user.error] (UKBRKR1P_B.LZ_
BENCHMARKS)[30]BIP2648E: Message backed out to a queue; node 'com.morleyfm.eai.b
enchmark.RetrieveBenchmarksFromODR.EAI.BENCHMKS.WBI.WBI.FlowInput'. : UKBRKR1P_B
.40b370fc-1901-0000-0080-d51319f22e3a: /build/S500_P/src/DataFlowEngine/ImbMqInp
utNode.cpp: 3477: ImbMqInputNode::eligibleForBackout: ComIbmMQInputNode: com/mor
leyfm/eai/benchmark/RetrieveBenchmarksFromODR#FCMComposite_1_1.com/morleyfm/eai/
common/GlobalInputSub#FCMComposite_1_1

Jan 17 02:47:43 srim6165 MQSIv500[22581]: [ID 702911 user.error] (UKBRKR1P_B.LZ_
BENCHMARKS)[30]BIP2232E: Error detected whilst handling a previous error in node
'com.morleyfm.eai.benchmark.RetrieveBenchmarksFromODR.EAI.BENCHMKS.WBI.WBI.Thro
w'. : UKBRKR1P_B.40b370fc-1901-0000-0080-d51319f22e3a: /build/S500_P/src/DataFlo
wEngine/ImbDataFlowNode.cpp: 387: ImbDataFlowNode::logExceptionList: ComIbmThrow
Node: com/morleyfm/eai/benchmark/RetrieveBenchmarksFromODR#FCMComposite_1_1.com/
morleyfm/eai/common/GlobalInputSub#FCMComposite_1_5
Jan 17 02:47:43 srim6165 MQSIv500[22581]: [ID 702911 user.error] (UKBRKR1P_B.LZ_
BENCHMARKS)[30]BIP2230E: Error detected whilst processing a message in node 'com
.morleyfm.eai.benchmark.RetrieveBenchmarksFromODR.EAI.BENCHMKS.WBI.WBI.FlowEnvir
onment'. : UKBRKR1P_B.40b370fc-1901-0000-0080-d51319f22e3a: /build/S500_P/src/Da
taFlowEngine/PluginInterface/ImbJniNode.cpp: 892: ImbJniNode::evaluate: ComIbmJn
iNode: com/morleyfm/eai/benchmark/RetrieveBenchmarksFromODR#FCMComposite_1_1.com
/morleyfm/eai/common/GlobalInputSub#FCMComposite_1_2

Jan 17 02:47:43 srim6165 MQSIv500[22581]: [ID 702911 user.error] (UKBRKR1P_B.LZ_
BENCHMARKS)[30]BIP2230E: Error detected whilst processing a message in node 'com
.morleyfm.eai.benchmark.RetrieveBenchmarksFromODR.EAI.BENCHMKS.WBI.WBI.Begin'. :
UKBRKR1P_B.40b370fc-1901-0000-0080-d51319f22e3a: /build/S500_P/src/DataFlowEngi
ne/PluginInterface/ImbJniNode.cpp: 902: ImbJniNode::evaluate: ComIbmJniNode: com
/morleyfm/eai/benchmark/RetrieveBenchmarksFromODR#FCMComposite_1_1.com/morleyfm/
eai/common/GlobalInputSub#FCMComposite_1_8

Jan 17 02:47:43 srim6165 MQSIv500[22581]: [ID 702911 user.error] (UKBRKR1P_B.LZ_
BENCHMARKS)[30]BIP2230E: Error detected whilst processing a message in node 'com
.morleyfm.eai.benchmark.RetrieveBenchmarksFromODR.Global_Exception_Format_sub.EA
I.HUB.EXCEPTION.IN.ANY.WBI'. : UKBRKR1P_B.40b370fc-1901-0000-0080-d51319f22e3a:
/build/S500_P/src/DataFlowEngine/ImbMqOutputNode.cpp: 849: ImbMqOutputNode::eval
uate: ComIbmMQOutputNode: com/morleyfm/eai/benchmark/RetrieveBenchmarksFromODR#F
CMComposite_1_5.Global_Exception_Format_sub#FCMComposite_1_1

Jan 18 02:47:43 srim6165 MQSIv500[22581]: [ID 702911 user.error] (UKBRKR1P_B.LZ_
BENCHMARKS)[30]BIP2628E: Exception condition detected on input node 'com.morleyf
m.eai.benchmark.RetrieveBenchmarksFromODR.EAI.BENCHMKS.WBI.WBI.FlowInput'. : UKB
RKR1P_B.40b370fc-1901-0000-0080-d51319f22e3a: /build/S500_P/src/DataFlowEngine/I
mbMqInputNode.cpp: 2127: ImbMqInputNode::readQueue: ComIbmMQInputNode: com/morle
yfm/eai/benchmark/RetrieveBenchmarksFromODR#FCMComposite_1_1.com/morleyfm/eai/co
mmon/GlobalInputSub#FCMComposite_1_1

Jan 18 02:47:44 srim6165 MQSIv500[22581]: [ID 702911 user.error] (UKBRKR1P_B.LZ_
BENCHMARKS)[30]BIP2648E: Message backed out to a queue; node 'com.morleyfm.eai.b
enchmark.RetrieveBenchmarksFromODR.EAI.BENCHMKS.WBI.WBI.FlowInput'. : UKBRKR1P_B
.40b370fc-1901-0000-0080-d51319f22e3a: /build/S500_P/src/DataFlowEngine/ImbMqInp
utNode.cpp: 3477: ImbMqInputNode::eligibleForBackout: ComIbmMQInputNode: com/mor
leyfm/eai/benchmark/RetrieveBenchmarksFromODR#FCMComposite_1_1.com/morleyfm/eai/
common/GlobalInputSub#FCMComposite_1_1

Jan 18 08:42:17 srim6165 MQSIv500[22576]: [ID 702911 user.error] (UKBRKR1P_B.ROU
TING2)[38]BIP2232E: Error detected whilst handling a previous error in node 'com
.morleyfm.eai.routers.JPMCentralGatewayHandler.EAI.COMMON_NON_SEQ.JPM.WBI.Throw'
. : UKBRKR1P_B.13e26cfc-1901-0000-0080-d51319f22e3a: /build/S500_P/src/DataFlowE
ngine/ImbDataFlowNode.cpp: 387: ImbDataFlowNode::logExceptionList: ComIbmThrowNo
de: com/morleyfm/eai/routers/JPMCentralGatewayHandler#FCMComposite_1_1.com/morle
yfm/eai/common/subflows/CommonInputSub#FCMComposite_1_5


Now i want to search that string for date Jan 17..How do I extract the contents of Jan 17 using shell script so that i can go ahead with the search ?

Thanks in advance !!
  #2 (permalink)  
Old 01-20-2009
ynilesh's Avatar
ynilesh ynilesh is offline
Registered User
  
 

Join Date: Oct 2007
Location: Bangalore, India.
Posts: 222
You can grep for "Jan 17".
Quote:
cat log.file | grep "Jan 17"
  #3 (permalink)  
Old 01-20-2009
charudpss charudpss is offline
Registered User
  
 

Join Date: Jan 2009
Posts: 9
Hi ,
Thanks for the reply.But this will only give the first line containing Jan 17 from the log file.I need all the lines.
  #4 (permalink)  
Old 01-20-2009
danmero danmero is online now Forum Advisor  
  
 

Join Date: Nov 2007
Location: 45.48-73.63
Posts: 1,449
Try awk.

Code:
awk '$1==month && $2!=day{f=0}$1==month && $2==day{f=1}f' month=Jan day=17 file

  #5 (permalink)  
Old 01-20-2009
charudpss charudpss is offline
Registered User
  
 

Join Date: Jan 2009
Posts: 9
Thanks danmero !!...
Can I pass the month and date as command line argument in this code as i will be using this awk in a shell script.
  #6 (permalink)  
Old 01-20-2009
charudpss charudpss is offline
Registered User
  
 

Join Date: Jan 2009
Posts: 9
Hi,
Thanks alot.The Problem is solved now.
  #7 (permalink)  
Old 01-20-2009
ynilesh's Avatar
ynilesh ynilesh is offline
Registered User
  
 

Join Date: Oct 2007
Location: Bangalore, India.
Posts: 222
Quote:
cat log.file | grep -B 5 "Jan 17"
This will print below 5 lines of the search.

-nilesh
Closed Thread

Bookmarks

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 09:05 AM.


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