I have the following log file. I need to know if there are any fault / suspect condition using a shell script.
I need to find fault and check the previous word, if it is greater than 0 then there is a work for the DBA.
Checking pubs2: Logical pagesize is 4096 bytes DBCC CHECKSTORAGE for database 'pubs2' sequence 17 completed at Oct 21 2015 3:17PM. 4 faults and 0 suspect conditions were located. 0 checks were aborted. You should investigate the recorded faults, and plan a course of action that will correct them.
I already tried the following commands in Linux/Bash shell and it is working well.
FLTCNT=`cat $MAILLOG | grep -oP '\S+(?=\s+faults and)'` SPTCNT=`cat $MAILLOG | grep -oP '\S+(?=\s+suspect)'` if [ $FLTCNT -gt 0 ] || [ $SPTCNT -gt 0 ] ; then FAILED="Y" # echo "Fault / suspect conditions found" cat $MAILLOG >> $ERRLOG fi
But when I execute the same in an AIX server I am getting error
grep: illegal option -- o grep: illegal option -- P usage: grep [-r] [-R] [-H] [-L] [-E|-F] [-c|-l|-q] [-insvxbhwyu] [-p[parasep]] -e pattern_list... [-f pattern_file...] [file...] usage: grep [-E|-F] [-c|-l|-q] [-insvxbhwyu] [-p[parasep]] [-e pattern_list...] -f pattern_file... [file...]