
Extracting text from a file
I am trying to write a script to extract errors if any from a log file on a
daily basis. So far I can find the date in the file by using:
C_DATE=`date +"%a %b %e "`
and then sed to copy the file to a temp file using
sed -n "/^$C_DATE/,$ p" alert.log > tempfile
However this copies the whole file over to tempfile. What I want to do is
just copy everything from that point down in the file to tempfile. So in the
log extract below I would copy everything from 'Wed Apr 23 13:25:01 2003' to
tempfile.
.
.
Wed Apr 23 13:25:01 2003
ARC1: Evaluating archive log 1 thread 1 sequence 19357
ARC1: Beginning to archive log 1 thread 1 sequence 19357
Creating archive destination LOG_ARCHIVE_DEST_1:
'/arch/ATMP/arch_1_19357.arc'
ARC1: Completed archiving log 1 thread 1 sequence 19357
Wed Apr 23 14:29:45 2003
ORA-000060: Deadlock detected. More info in file
/u01/app/oracle/admin/ATMP/udump/atmp_ora_16401.trc.
Wed Apr 23 14:29:50 2003
What I do next is extract the ORA- erorrs to another file using
sed -n '/^ORA-/ p' tempfile > ora_errors
and then email it to me. Can anyone tell me how to cut text from a
particular point in a file or suggest a better way of doing what I am trying
to achieve
Thanks for any help