Hi Everybody:
I have a question
This is my program:
#!/bin/csh -f
set month = `date +%b`
set day = `date +%e`
@ yesterday = $day - 1
set yes = $yesterday
if ($yes == 0) then
if ($month == Jan) then
set month = Dec
set yes = 31
endif
if ($month == Feb) then
set month = Jan
set yes = 31
endif
.........................
.........................
if ($month == Mar) then
@ leapyear = `date +%C` %4
set month = Feb
set month = Feb
set yes = 28
if ($leapyear == 0) yes = 29
endif
else
set yestermonth = $month
endif
nawk 'BEGIN { rightday = 0; dateline = "" } $2~~ /'$month'/ && $3 ~~ /'$yes'/ { rightday = 1; dateline = $0 }$2~~ /'$month'/ && $3 ~~ /'$day'/ {exit} rightday == 1 && /ORA/ {print dateline;print}' alert_mes.log
Then I got :
Wed Oct 2 18:25:16 2002
ORA-12012: error on auto execute of job 134
Wed Oct 2 18:25:16 2002
ORA-12541: TNS:no listener
Wed Oct 2 18:25:16 2002
ORA-06512: at "SYS.DBMS_SNAPSHOT", line 794
Wed Oct 2 18:25:16 2002
ORA-06512: at "SYS.DBMS_SNAPSHOT", line 851
But I wanted :
[COLOR=#ffoooo]
Wed Oct 2 18:25:16 2002
Errors in file /raid1/app/oracle/admin/mes/bdump/mes_j000_5985.trc:
ORA-12012: error on auto execute of job 150
ORA-12541: TNS:no listener
ORA-06512: at "SYS.DBMS_SNAPSHOT", line 794
ORA-06512: at "SYS.DBMS_SNAPSHOT", line 851
[/color]
The original file is :
italic
................................................
.................................................
Wed Oct 2 18:25:16 2002
normal xxxxxxxxxxxxxxxxxxxx
Wed Oct 2 18:25:16 2002
Errors in file /raid1/app/oracle/admin/mes/bdump/mes_j000_5985.trc:
ORA-12012: error on auto execute of job 150
ORA-12541: TNS:no listener
ORA-06512: at "SYS.DBMS_SNAPSHOT", line 794
ORA-06512: at "SYS.DBMS_SNAPSHOT", line 851
................................................
That is to say if it meet the "ORA" words I wanted to print all lines which are below the date.
Thank you very much.
piggy
I have a question
This is my program:
#!/bin/csh -f
set month = `date +%b`
set day = `date +%e`
@ yesterday = $day - 1
set yes = $yesterday
if ($yes == 0) then
if ($month == Jan) then
set month = Dec
set yes = 31
endif
if ($month == Feb) then
set month = Jan
set yes = 31
endif
.........................
.........................
if ($month == Mar) then
@ leapyear = `date +%C` %4
set month = Feb
set month = Feb
set yes = 28
if ($leapyear == 0) yes = 29
endif
else
set yestermonth = $month
endif
nawk 'BEGIN { rightday = 0; dateline = "" } $2~~ /'$month'/ && $3 ~~ /'$yes'/ { rightday = 1; dateline = $0 }$2~~ /'$month'/ && $3 ~~ /'$day'/ {exit} rightday == 1 && /ORA/ {print dateline;print}' alert_mes.log
Then I got :
Wed Oct 2 18:25:16 2002
ORA-12012: error on auto execute of job 134
Wed Oct 2 18:25:16 2002
ORA-12541: TNS:no listener
Wed Oct 2 18:25:16 2002
ORA-06512: at "SYS.DBMS_SNAPSHOT", line 794
Wed Oct 2 18:25:16 2002
ORA-06512: at "SYS.DBMS_SNAPSHOT", line 851
But I wanted :
[COLOR=#ffoooo]
Wed Oct 2 18:25:16 2002
Errors in file /raid1/app/oracle/admin/mes/bdump/mes_j000_5985.trc:
ORA-12012: error on auto execute of job 150
ORA-12541: TNS:no listener
ORA-06512: at "SYS.DBMS_SNAPSHOT", line 794
ORA-06512: at "SYS.DBMS_SNAPSHOT", line 851
[/color]
The original file is :
italic
................................................
.................................................
Wed Oct 2 18:25:16 2002
normal xxxxxxxxxxxxxxxxxxxx
Wed Oct 2 18:25:16 2002
Errors in file /raid1/app/oracle/admin/mes/bdump/mes_j000_5985.trc:
ORA-12012: error on auto execute of job 150
ORA-12541: TNS:no listener
ORA-06512: at "SYS.DBMS_SNAPSHOT", line 794
ORA-06512: at "SYS.DBMS_SNAPSHOT", line 851
................................................
That is to say if it meet the "ORA" words I wanted to print all lines which are below the date.
Thank you very much.
piggy