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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
search by modified date kotasateesh Shell Programming and Scripting 4 06-24-2008 06:59 AM
Perl: Search for string on line then search and replace text Crypto Shell Programming and Scripting 4 01-04-2008 06:24 AM
Search files between a date range zcanji Shell Programming and Scripting 4 09-05-2007 12:38 AM
find file with date and recursive search for a text rosh0623 UNIX for Advanced & Expert Users 10 08-16-2006 11:27 AM
Search by modification date slink UNIX for Dummies Questions & Answers 5 05-25-2006 03:07 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-23-2007
Registered User
 

Join Date: Sep 2007
Posts: 3
Stumble this Post!
date search

Hi

Need to serach a file after a particular date for a pattren match

example:
1) ldr.out => last run date is stored in which has value 2007-09-20
2) dberror.log => captures all db errors with date
Requirement
==========
shell script to get the ldr.out date value and search the file dberror.log for particular pattern "dbcrash" after 2007-09-20 till date
if it exists
echo "dbcrash has happened after | 2007-09-20 "

else
exit

Thanks
Thiru
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 09-23-2007
jaduks's Avatar
Registered User
 

Join Date: Aug 2007
Location: Assam,India
Posts: 145
Stumble this Post!
thirumaran , could you please input some sample ldr.out and dberror.log contents, if possible, that will be helpful.
Reply With Quote
  #3 (permalink)  
Old 09-23-2007
Technorati Master
 

Join Date: Mar 2005
Location: Large scale systems...
Posts: 2,547
Stumble this Post!
from pattern to end of the file

Code:
awk '/pattern/, /\$/ { print }' filename
Reply With Quote
  #4 (permalink)  
Old 09-23-2007
Registered User
 

Join Date: Sep 2007
Posts: 3
Stumble this Post!
This file has the last run date
[Servername:/home/out]cat sample_lrd.out
2007-09-20



dberror.log

[:/home/db2inst1/sqllib/db2dump]cat db2diag.log
Unreserved memory left in set : 573440 bytes.

2007-09-20-14.39.47.703273-420 E29493A716 LEVEL: Warning
PID : 630882 TID : 1 PROC : db2agent (SAMPLE) 0
INSTANCE: db2inst1 NODE : 000 DB : SAMPLE
APPHDL : 0-52 APPID: *LOCAL.db2inst1.070923213947
FUNCTION: DB2 UDB, SQO Memory Management, sqloMemLogPoolConditions, probe:10
DATA #1 : <preformatted>
DBM_DB memory set automatically extended for Backup/Restore/Util Heap (UTIL_HEAP_SZ) on node 0.
Requested block size : 33558543 bytes.
Physical heap size : 201605120 bytes.
Heap reserved size : 20496384 bytes.
Unreserved memory used by heap : 181108736 bytes.
Unreserved memory left in set : 573440 bytes.

2007-09-23-14.39.47.706826-420 E30210A716 LEVEL: Warning
PID : 630882 TID : 1 PROC : db2agent (SAMPLE) 0
INSTANCE: db2inst1 NODE : 000 DB : SAMPLE
APPHDL : 0-52 APPID: *LOCAL.db2inst1.070923213947
FUNCTION: DB2 UDB, SQO Memory Management, sqloMemLogPoolConditions, probe:10
DATA #1 : <preformatted>
DBM_DB memory set automatically extended for Backup/Restore/Util Heap (UTIL_HEAP_SZ) on node 0.
Requested block size : 33558543 bytes.
Physical heap size : 235175936 bytes.
Heap reserved size : 20496384 bytes.
Unreserved memory used by heap : 214679552 bytes.
Unreserved memory left in set : 573440 bytes.

2007-09-23-14.39.47.710385-420 E30927A716 LEVEL: Warning
PID : 630882 TID : 1 PROC : db2agent (SAMPLE) 0
INSTANCE: db2inst1 NODE : 000 DB : SAMPLE
APPHDL : 0-52 APPID: *LOCAL.db2inst1.070923213947
FUNCTION: DB2 UDB, SQO Memory Management, sqloMemLogPoolConditions, probe:10
DATA #1 : <preformatted>
DBM_DB memory set automatically extended for Backup/Restore/Util Heap (UTIL_HEAP_SZ) on node 0.
Requested block size : 33558543 bytes.
Physical heap size : 268746752 bytes.
Heap reserved size : 20496384 bytes.
Unreserved memory used by heap : 248250368 bytes.
Unreserved memory left in set : 573440 bytes.
Reply With Quote
  #5 (permalink)  
Old 09-23-2007
Technorati Master
 

Join Date: Mar 2005
Location: Large scale systems...
Posts: 2,547
Stumble this Post!
Code:
awk -v var=`cat date_file` '{ if ( $0 ~ var ) { print } }' log_file
Reply With Quote
  #6 (permalink)  
Old 09-23-2007
Registered User
 

Join Date: Sep 2007
Posts: 3
Stumble this Post!
Madhan,

Thanks for ur help

awk -v var=`cat date_file` '{ if ( $0 ~ var ) { print } }' log_file

this will get the date and search for the pattern in log file .

can u help me in this
1) search for pattern 1 in log file ( ur awk cmd will work) if it exists then
2) then search for pattren2 from the last occurance of pattern1
3) if pattern2 exists
echo "pattern2 has happened after | date_file value "
fi

Regards
Thiru
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 10:07 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0