 <p>You can do this with "while read" and avoid awk if you prefer:</p> <pre><code>while read a b c d e f g h i; do if [ ${a:0:2} == "Ge" ]; then echo $h $i &gt;&gt; allgood.txt; elif [ ${a:0:2} == "ea" ]; then echo $c $d &gt;&gt; allgood.txt; fi; done &lt; abc.txt </code></pre> <p>The letters represent each column, so you'll need as many as you have columns. After that you just output the letters you need.</p>