I am trying to find strings Error:, Error :, ERROR:, ERROR : in a given file, if found then go to if block if not found then go to else block.
Below is the logic I had written to perform this operation.
#!/bin/bash
file='file.log'
text=`cat $file`
echo $text
if [[ ${text} = *Error:* ||${text} = *ERROR:*|| ${text} = *ERROR :* || ${text} = *Error :* || $? -ne 0 ]]; then
STATUS=1
echo "=> string found."
else
echo "=> no string found."
fi
Seems like this logic is having issues as its returning below error.
syntax error near `:*'
Can someone please help me in resolving this issue?
grep -iq 'error \{0,1\}:' file.log?