title: conditional deletion of lines in xml file using sed
body: <p>This question may not have a straight forward answer... if so, not to worry. I have an XML file that looks something like </p>
  
  <pre><code>&lt;a&gt;0.00&lt;/a&gt;
  &lt;b&gt;0.00&lt;/b&gt;
  &lt;c&gt;0.00&lt;/c&gt;
  &lt;d&gt;0.00&lt;/d&gt;
  </code></pre>
  
  <p>This is a dumbed down version of what i'm working with. My goal is to delete any line with a data point of zero, if and only if all data points are zero (as the example i've given above). Even if one of the lines in the file contains a non zero entry, i can't delete any of them. For example if the above was </p>
  
  <pre><code>&lt;a&gt;0.00&lt;/a&gt;
  &lt;b&gt;0.00&lt;/b&gt;
  &lt;c&gt;1.00&lt;/c&gt;
  &lt;d&gt;0.00&lt;/d&gt;
  </code></pre>
  
  <p>then the file should remain untouched. Ultimately, I only want to delete all lines if they all have zero in each and every tag, and leave the file as is otherwise. I know the following will work if all lines have a zero data entry.</p>
  
  <pre><code>sed --in-place '\|&gt;0.00&lt;/|d' $FILENAME 
  </code></pre>
  
  <p>However, if I have the second example below, this will leave me with </p>
  
  <pre><code>&lt;c&gt;1.00&lt;/c&gt;
  </code></pre>
  
  <p>which isn't what I'm looking for. I know I probably need an if statement, something like</p>
  
  <pre><code>if (all lines contain the string '&gt;0.00&lt;/') then
     sed --in-place '\|&gt;0.00&lt;/|d' $FILENAME 
  fi
  </code></pre>
  
  <p>I suppose its the condition in the if statement that i'm not sure about. How would I go about stating "if all lines contain the above mentioned string"? I dont necessarily have to use sed, I have used awk in the past, but I am most comfortable with sed.... Any input or pointers in the right direction would be most appreciated. Thanks</p>