title: Replace a value except at the end of a line
body: <p>So I have a text file that contains ASCII STX characters (targetable with \x02) sprinkled throughout. I want to remove them if they are NOT at the end of a line.</p>
  
  <pre><code># This removes all STX characters
  sed -i 's/\x02//g' foo.txt
  
  # This removes STX characters that are at the end of a line
  sed -i 's/\x02$//g' foo.txt
  </code></pre>
  
  <p>How does one remove the character if it is NOT at the end of the line?</p>