Data Validation

Hello,

I am trying to use data validation with a program. I have everything else working fine. I just can't figure out what I am doing wrong with the data validation in one of my files. Here is the code:

# data validation loop
     while :
     do

          # get input from keyboard
          echo "Please enter your search keyword(s):"
          read keywords

          # if statement
          if [ "$keywords" = "" ]

          # then statement
          then

               # display error message
               echo "Error, you have not entered keywords!"
               echo "Please try again."
               # continue data validation loop
               continue

          else

               # display good message
               echo "Great, keep going!"
               # break out of data validation loop
               break

          fi
          # end of if statement

     done
     # end of data validation loop

     # here document redirects input of a command from here
     cat<<alldone2

          ${bell}

alldone2
# end of here document

     # display keyword search matches
     grep -in "$keywords" $phonebook|sed -n -e 's/^/\
                        /' -e 's/:/\
                        /gp'


      # here document redirects input of a command from here
      cat<<alldone3

           ${bell}

 alldone3
 # end of here document

      # data validation loop
      while :
      do

           # get input from keyboard
           echo "Please enter the record number of the particular record to remove:�
           read number

           total = `cat $phonebook|wc -l`

           # if statement
           if [ "$number" != "" ]
           then if [ $number -ge 1 -a $number -le $total  ]

                then
                     #display message
                     echo "Great job, keep going!"
                     #break out of data validation loop
                     break

                else
                     #display error message
                     echo "The number is not in the range."
                     echo "Please try again."
                     # continue data validation loop
                     continue

                fi
                #end of if statement

           else

                #display error message
                echo "You did not enter a number!"
                #continue data validation loop
                continue

           fi
           # end of if statement

      done
      # end of validation loop

      # command substitution assigns the output of sed to record
      record=`sed -n ${number}p $phonebook`

      # remove the record using the number selected by the user
      grep -iv "$record" "$phonebook" > $tmp

      # rename tmp to phonebook
      mv $tmp $phonebook

      # change permissions for phonebook datafile
      chmod 755 $phonebook

      # get input from keyboard
      echo "Do you want to remove more records? \c"
      read answer

When I use verbose and execution trace, here is what I get:

+ :
+ echo Please enter your search keyword(s):
Please enter your search keyword(s):
+ read keywords
bob
+ [ bob =  ]
+ echo Great, keep going!
Great, keep going!
+ break
+ cat






+ sed -n -e s/^/\
                        / -e s/:/\
                        /gp
+ grep -in bob /fun/phonebook

                        3
                        bob again
                        778 bob lane
                        bob city
                        bob state
                        11111
                        1111111111
+ cat






+ :
+ echo Please enter the record number of the particular record to remove.
Please enter the record number of the particular record to remove.
+ read number
3
+ wc -l
+ cat /fun/phonebook
+ total = 3
remove: total: execute permission denied
+ [ 3 !=  ]
+ [ 3 -ge 1 -a 3 -le ]
remove: test: argument expected

Thank you,
Eric

is this is a typo?

 total = `cat $phonebook|wc -l`

if the above statement is used as such,
line count will not be assigned to total,

use

total=`cat $phonebook|wc -l`

I feel like a big dummy.

Thanks for pointing that out. That took care of my problem. I will continue practicing.

Thanks,
Eric