I want my shell can only find out the pattern in the quote,
but the result also returned something like "MSGxxxxx"
Here is my script:
if egrep -e 'Msg|duplicate|deadlock|status = -|terminated due to disconnect' MYFILE.log
then
echo "I found something in your RAW data."
else
echo "Nothing found!"
fi
Use the -w
flag in order to select only those lines containing matches that form whole words.
if egrep -w -e 'Msg|duplicate|deadlock|status = -|terminated due to disconnect' file
then
echo "I found something in your RAW data."
else
echo "Nothing found!"
fi
Alternatively, use a word boundary \b
as shown below:
if egrep -e '\bMsg\b|duplicate|deadlock|status = -|terminated due to disconnect' file
then
echo "I found something in your RAW data."
else
echo "Nothing found!"
fi