Hi
I would like to read two log files and compare the numbers.
If the difference is more than 5, email should be sent.
I want to grep the latest string start with "Media Recovery" and capture the log number.
Here it is 6465.
I would like to compare it with another logfile.
Sample Log file output
****************************************************
Media Recovery Log C:\ARCHIVE\ARCH6463_1_850416493.LOG
Mon Oct 20 10:10:05 2014
Media Recovery Log C:\ARCHIVE\ARCH6464_1_850416493.LOG
Errors with log C:\ARCHIVE\ARCH6464_1_850416493.LOG
ORA-279 signalled during: ALTER DATABASE RECOVER automatic from 'C:\archive' database until cancel using backup controlfile ...
Mon Oct 20 10:10:05 2014
ALTER DATABASE RECOVER CANCEL
Mon Oct 20 10:10:06 2014
Media Recovery Canceled
Completed: ALTER DATABASE RECOVER CANCEL
Mon Oct 20 11:10:00 2014
ALTER DATABASE RECOVER automatic from 'C:\archive' database until cancel using backup controlfile
Media Recovery Start
Mon Oct 20 11:10:01 2014
Media Recovery Log C:\ARCHIVE\ARCH6464_1_850416493.LOG
Mon Oct 20 11:10:17 2014
Media Recovery Log C:\ARCHIVE\ARCH6465_1_850416493.LOG
Errors with log C:\ARCHIVE\ARCH6465_1_850416493.LOG
ORA-279 signalled during: ALTER DATABASE RECOVER automatic from 'C:\archive' database until cancel using backup controlfile ...
Mon Oct 20 11:10:17 2014
ALTER DATABASE RECOVER CANCEL
Mon Oct 20 11:10:17 2014
Media Recovery Canceled
Completed: ALTER DATABASE RECOVER CANCEL
****************************************************
In unix, I can achive this something like following:
x1= grep 'Media Recovery Log ' alert1.log | tail -1 | awk '{print $4}'| cut -d'_' -f2 | cut -d'.' -f1
echo $x1
6465
x2 grep 'Media Recovery Log ' alert2.log | tail -1 | awk '{print $4}'| cut -d'_' -f2 | cut -d'.' -f1
echo $x2
6462
if x1-x2 >5
.....
Not sure how to do same in powershell