I have a requirement to check if exists clause for all DROP TABLE statements.
If IF EXISTS clause is not present, the script should print it. Below is my code. It works correctly, However I have to check this for all cases. Below scenario works only for uppercase.
for f in $FILES
do
result=`grep "DROP \+TABLE" "$f" | grep -v "IF \+EXISTS"` # -v inverts the match
if [ ! -z $result ]
then
echo 'IF EXISTS clause not found ' $f ':' $result
fi
done