grep spaces

Hi all,
I'm writing a program that scans a file for a name and/or number the user enters ie:
$ sh phone.sh "Sally Turner"
or
$ sh phone.sh Bob 12345678

I've got it mostly working except when I use "" to try make a full name one argument ie "sally turner" it scans for a turner file in the current directory or when "Sally Turner" 12345678 is entered searches for Turner12345678. I think the "" are not removing the space making it read:

grep "Sally Turner" directory.txt 

as

grep Sally Turner directory.txt 

My question is does grep have an option that fixes this problem?
Here's the chunk of code with the problem:


        grep $1$2 directory.txt > /dev/null
        work=$?
        if [ $work -ne 1 ]
        then
        grep $1$2 directory.txt
        else
        echo "Adding new entry to directory..."
        $input >> directory.txt
        sleep 1
        echo "Entry added"

For character or symbol searches you should preface the string with quotes inside the code and send a quoted input to ensure that the grep will work.

i.e. grep "$1" directory.txt > /dev/null

./phone.sh "search for this text"

grep "$1 $2" directory.txt > /dev/null

Ot, if there could be one or two words:

grep "$1${2:+" $2"}" directory.txt > /dev/null

Or:

grep "$1 *$2" directory.txt > /dev/null

YAY! it's finnaly all working correctly. I needed both "" around the single input variables and the 2 input variables so now it recognises input with "" as one input not two. Thankyou both very much for your help! :smiley: