Visit Our UNIX and Linux User Community


date search


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting date search
# 1  
Old 09-24-2007
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
# 2  
Old 09-24-2007
thirumaran , could you please input some sample ldr.out and dberror.log contents, if possible, that will be helpful.
# 3  
Old 09-24-2007
from pattern to end of the file

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

# 4  
Old 09-24-2007
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.
# 5  
Old 09-24-2007
Code:
awk -v var=`cat date_file` '{ if ( $0 ~ var ) { print } }' log_file

# 6  
Old 09-24-2007
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

Previous Thread | Next Thread
Test Your Knowledge in Computers #747
Difficulty: Medium
The Z80 uses 248 out of the available 256 codes as single byte opcodes.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

UNIX: Search file between two Date stamps

Hi, I have a requirement to find a file based on date stamp provided by user. In one of the shared location I get data file say “datafile<dataformat>“. And User will provide the date based on which I need to select a file which is 7 days older, if a file not present within 7 days, then I need... (3 Replies)
Discussion started by: santhosh86467
3 Replies

2. Shell Programming and Scripting

How to search file for a date variable?

Hello, I'm trying to write a ksh script which will allow me to to search for yesterday's date within a rtf file. I just need someway to know if the date is in the file, echo results to a text file, and then mail that out. The format of the date is mm/dd/yyyy. I had to make a variable... (2 Replies)
Discussion started by: ronan1219
2 Replies

3. Shell Programming and Scripting

How to search log file from a date

Hi All, I want to grep through all the log files created from 20th August. How do I do that? My script will run everyday. So it will take current date as To_Date. My log file name looks like - applog-2012-08-20-000001....applog-2012-08-20-000002...etc. Thanks in advance. (5 Replies)
Discussion started by: kmajumder
5 Replies

4. Shell Programming and Scripting

How to search for file and display by date

I like "ls -ltr". I would like to search for a file in a large directory recursively and and display all the candidates in reverse order. /usr/bin/find . -name \*.txt This works. How do I display the date and sort the file names by the date in reverse order for the entire directory... (1 Reply)
Discussion started by: siegfried
1 Replies

5. Shell Programming and Scripting

Search for files on a particular date

I have list of files generated on 2 dates which are shown below: -rw-r----- 1 bobby ccsdba 580945 Aug 16 16:13 file 1 -rw-r----- 1 bobby ccsdba 580945 Aug 16 16:16 file 2 -rwxrwxr-x 1 Shaan ccsdba 4422724 Aug 16 16:28 file 3 -rwxrwxr-x 1 bobby ccsdba 794 ... (1 Reply)
Discussion started by: bobby1015
1 Replies

6. Solaris

search for date of modification

hi member. i want to know all file in the system which the last date of modification = 14-06-2010 for example what can i do (4 Replies)
Discussion started by: xxmasrawy
4 Replies

7. Shell Programming and Scripting

Search files between a date range

Hi people A newbie here, thrown into the deep end. I want to select the group of files with in a range of dates and perform some operation on it. Are there inbuild date libraries i can use? I did read thru the old posts on this topic. Couldnt get much idea :(, basically want to know how I... (7 Replies)
Discussion started by: zcanji
7 Replies

8. UNIX for Dummies Questions & Answers

Search for a file with Current Date

Hi, How can we search for a file with current date(sysdate). Actually i want the file name from a directory which was created today(current date). For example i have a dir /home/arch and i have files with name aglito03axyz.datetimestamp in this directory, but all these files were created... (7 Replies)
Discussion started by: sandeep_1105
7 Replies

9. Shell Programming and Scripting

search by modified date

Hello, How can i search for all the files in a particular directory which are not updated from past 5 days. Thanks, Sateesh (4 Replies)
Discussion started by: kotasateesh
4 Replies

10. UNIX for Dummies Questions & Answers

Search by modification date

Hi I'd like to know if is it possible to find files given a certain modification date (say, 01-05-2006, that's 1st of May 2006) I can calculate the days backward: find / -ctime 23 but I wish to search by exact modification day Thanks (5 Replies)
Discussion started by: slink
5 Replies

Featured Tech Videos