title: How do I search replace conditionally with awk or sed?
body: <p>A file with this content:</p>
  <pre><code>var1 = true
  </code></pre>
  <p>How do I toggle this value with sed/awk?</p>
  <p>I looked into groups, sed addresses..but nowhere does it say how to save a return value like &quot;found it&quot; or &quot;not found it&quot;.
  Search replace <code>var1 = true</code> to <code>var1 = false</code></p>
  <p><strong>edit</strong>: doesn't seem to write into the file ..ever:</p>
  <pre><code>sed 's/var1 = true/var1 = foo/g' ./variables1
  sed 's/var1 = false/var1 = true/g' ./variables1
  sed 's/var1 = foo/var1 = false/g' ./variables1
  </code></pre>
  <p>command line output:</p>
  <blockquote>
  <p>var1 = foo</p>
  <p>var1 = true</p>
  <p>var1 = true</p>
  </blockquote>
  <p>weird</p>
  <p><strong>edit2</strong>: it worked with sed -i for inplace editing</p>