I have a log file created while running a script.
I want to check the same log file for any messages with 'Msg ....' and exit the code except with this 'Msg 2714'.
So, I had added the below code into my script:
Some line of code before
rc1=`grep -v 'Msg 2714' $Logfilename`
rc2=`grep -i 'Msg' $rc1`
if [ $rc2 -ne "" ]
then
echo "Error message, some query has failed"
exit
fi
But, i have been encountering through a problem with the grep command, even though the second grep returns null the exit code/return code is '1' so the- "if commands fails and the exists the script".
Please provide any suggestion if any thing was wrong here?
Thank you!
$rc1
is not a valid filename. – Ipor Sircer Oct 25 '18 at 14:12