Unix - Return first and last row of a similar value
<p>I have a table like this:</p>

<pre><code>1000    2000    Ally  
1001    2001    Ally  
1002    2002    Ally  
1003    2003    Ally  
2000    4000    Kate  
2010    4010    Kate  
2020    4020    Kate  
3000    9000    Lisa
</code></pre>

<p>I would like for it to return the first and the last line when the 3rd column has the same value. In this case it would return:</p>

<pre><code>1000    2000    Ally  
1003    2003    Ally  
2000 4000 Kate  
2020 4020 Kate  
3000    9000    Lisa
</code></pre>

<p>Anyway of using <code>awk</code>/<code>sed</code>/<code>grep</code> to do this? Thanks.</p>