title: I want to compare one line to the next line, but only in the third column, from a file using bash
body: <p>So, what I'm trying to do is read in a file, loop through it comparing it line by line, but only in the third column. Sorry if this doesn't make sense, but maybe this will help. I have a file of names:
   <code>
   JOHN SMITH SMITH
   JIM JOHNSON JOHNSON
   JIM SMITH SMITH</code></p>
  
  <p>I want to see if (first, col3)SMITH is equal to JOHNSON, if not, move onto the next name. If (first, col3) SMITH is equal to (second, col3) SMITH, then I'll do something with that. 
  Again, I'm sorry if this doesn't make much sense, but I tried to explain it as best as I could.
  I was attempting to see if they were equal, but obviously that didn't work. Here is what I have so far, but I got stuck:</p>
  
  <pre><code>while read -a line
  do
      if [ ${line[2]} == ${line[2]} ]
      then
              echo -e "${line[2]}" &gt;&gt; names5.txt
      else
              echo "Not equal."
      fi
  done &lt; names4.txt
  </code></pre>