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

thirumaran , could you please input some sample ldr.out and dberror.log contents, if possible, that will be helpful.

from pattern to end of the file

awk '/pattern/, /\$/ { print }' filename

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.

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

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