title: awk: if condition is met, add string to these lines
body: <p>I am trying to combine these two commands:</p>
  
  <pre><code>awk -F[' '] '{if ($1=="string" || $4=="string") print $0" ""blue"}' file &gt;file.out 
  awk -F[' '] '{if ($1!="string" &amp;&amp; $4!="string") print $0}' file &gt;&gt;file.out
  </code></pre>
  
  <p>Basically I want to add a column, but only print <code>blue</code> in that column if either the first or the fourth column are equal to a <code>string</code>.</p>
  
  <p>input:</p>
  
  <pre><code>string 123 452 abc
  def 420 902 ghi 
  </code></pre>
  
  <p>expected output:</p>
  
  <pre><code>string 123 452 abc blue
  def 420 902 ghi 
  </code></pre>