title: grep command in an if statement
body: <pre><code>#!/bin/bash
  read -p &quot;enter search term here: &quot; searchT
  
  if [[ $(cat test.txt | grep -wi '$searchT') ]]; then     
      echo &quot;$(cat test.txt | grep '$searchT' &amp;&amp; wc -l) number of matches found&quot;
      echo $(cat test.txt | grep '$searchT')
  
  else echo &quot;no match found&quot;    
  
  fi
  
  exit 0
  </code></pre>
  <p>How do I make the script run if the <code>if statement</code> is true. when i run the script the script will output the <code>else</code> statement. because there is no value to compare with the grep command.</p>