Help with if statement in ksh script

I need a way to grep for a string in a file and if it finds it, to print set a variable to "Yes", if it doesn't find the string in a file to set the variable to "No". I plan on using these variables to print a table that lists whether the string was found or not.

For example

print "File     "String1"
print "--     "-------"
for file in `symcfg list | grep ^"    0" | cut -c13-16 | sort`
do
{
if
[ 'grep string1 $file 2>&1 /dev/null ']
then
string1=yes
else 
string1=no
fi
print $file $string1
}
done

This doesn't work since string1 is always going to be equal to yes even if the string is not found.

Here is the entire short script:

print "Symm ID          Verizon_Performance_Window      Verizon_Swap_Window"
echo "-------           --------------------------      -------------------"
for Symm in `symcfg list | grep ^"    0" | cut -c13-16 | sort`
do
{
        symoptmz -sid $Symm -parms show > Symopt_Check_$Symm
        if 
                [ 'grep Verizon_Performance_Window Symopt_Check_$Symm 2>&1 /dev/null' ]
                 then
                 VPW=Yes
        else
                 VPW=No
        fi
        if 
                [ 'grep Verizon_Swap_Window Symopt_Check_$Symm 2>&1 /dev/null' ]
                then
                VSW=Yes
        else
                VSW=No
        fi
        print $Symm "                   " $VPW "                                " $VSW
}
done

Try replacing the if-else-fi loops with this:

grep Verizon_Performance_Window Symopt_Check_$Symm 2>&1 /dev/null
if [ $? -eq 0 ]; then
                 VPW=Yes
else
                 VPW=No
fi
grep Verizon_Swap_Window Symopt_Check_$Symm 2>&1 /dev/null
if [ $? -eq 0 ]; then
                VSW=Yes
else
                VSW=No
fi

Note- this is not tested.

You can also use -q option of the grep command :

if grep -q Verizon_Performance_Window Symopt_Check_$Symm
then
                 VPW=Yes
else
                 VPW=No
fi
if grep -q Verizon_Swap_Window Symopt_Check_$Symm
then
                VSW=Yes
else
                VSW=No
fi

Jean-Pierre.