title: Awk vs Awk + cut vs. bash
body: <p>We all know that there are always multiple ways to solve a problem. I was wondering what the upsides and downsides of each of the particular solutions in one case would be. Time- and space-wise (and maybe cleanness - but that is subjective, so not the main focus). </p>
  
  <p>You got a file, that also contains lines which include the string <code>xyz</code>, but not exclusively. You are interested in lines where in a particular column the integer value should fullfil a condition. </p>
  
  <p>An example where I used this would be to filter the weak ciphers from an sslscan output. This is not particular time nor space intensive, so this example was only to have a clearer picture of how that could look like.</p>
  
  <p>The question came up, while I was trying to look for a solution, and I found various different answers on stackoverflow and then also came up with something myself. </p>
  
  <p>Possible solution 1 (pure awk):</p>
  
  <p><code>awk '$0~/xyz/ &amp;&amp; $3 &lt; 128 {$1=""; print}' file-with-data.txt</code></p>
  
  <p>Possible solution 2 (awk + cut):</p>
  
  <p><code>awk '$0~/xyz/ &amp;&amp; $3 &lt; 128' file-with-data.txt | cut -c15-</code></p>
  
  <p>Possible solution 3 (bash):</p>
  
  <pre><code>grep xyz file-with-data.txt | while read -r line
  do if [ $(echo $line | cut -d" " -f3)  -le 127 ]
     then echo $line
     fi
  done
  </code></pre>