title: IF statement for LINUX
body: <p>Modify your program so that if no matching name is found, a message is displayed: "Name 'xyz' not in directory". You could use an 'if' statement to check the value of $? to see if the grep command was successful (remember that '0' indicates success). If the grep is NOT successful, then echo the message (which includes the value of $name).</p>
  
  <p>The original code was:</p>
  
  <pre><code>#!/bin/bash
  
  name=$1
  
  if [ "$name" = "" ]
  then echo -n "Enter a name to search for: "
  
  read name
  
  fi
  
  grep -I $name ~uli101/2017a/phonebook
  </code></pre>
  
  <p>I basically have to insert and IF statement into the program using the instructions above. I've tried many different things such as:</p>
  
  <pre><code>if [ $? = 1 ]
  then echo -n "Name 'xyz' not in directory"
  fi
  </code></pre>
  
  <p>but it is not accepting the answer. Pls help me out with this. Any help is appreciated.</p>