Hello and welcome to LinuxQuestions,
Assign the command to a variable and then test the variable with your if statement:
Code:
variable=`egrep 'title dos([[:space:]]*)?$' filename`
I'll leave the if statement to you since this sounds a bit like homework to me
Kind regards,
Eric