How to give a pattern for new line in grep?

grep patterns are matched against individual lines so there is no way for a pattern to match a newline found in the input.

However you can find empty lines like this:

grep '^$' file
grep '^[[:space:]]*$' file # include white spaces 

bash: check if variable is set

The following is how you can check if variable is set:

if [ ! -z "$VAR1" ] && [ ! -z "$VAR2" ]
then
  echo "Variables VAR1 and VAR2 are set or not empty"
else
  echo "Variables are empty"
fi