title: sed/awk or other: one-liner to increment a number by 1 keeping spacing characters
body: <p><strong>EDIT</strong>: I don't know in advance at which "column" my digits are going to be and I'd like to have a one-liner. Apparently sed doesn't do arithmetic, so maybe a one-liner solution based on awk?</p>
  
  <p>I've got a string: (notice the spacing)</p>
  
  <pre><code>eh oh    37
  </code></pre>
  
  <p>and I want it to become:</p>
  
  <pre><code>eh oh    36
  </code></pre>
  
  <p>(so I want to keep the spacing)</p>
  
  <p>Using <em>awk</em> I don't find how to do it, so far I have:</p>
  
  <pre><code>echo "eh oh   37" | awk '$3&gt;=0&amp;&amp;$3&lt;=99 {$3--} {print}'
  </code></pre>
  
  <p>But this gives:</p>
  
  <pre><code>eh oh 36
  </code></pre>
  
  <p>(the spacing characters where lost, because the field separator is ' ')</p>
  
  <p>Is there a way to ask <em>awk</em> something like <em>"print the output using the exact same field separators as the input had"</em>?</p>
  
  <p>Then I tried yet something else, using awk's <em>sub(..,..)</em> method:</p>
  
  <pre><code>' sub(/[0-9][0-9]/, ...) {print}'
  </code></pre>
  
  <p>but no cigar yet: I don't know how to reference the regexp and do arithmetic on it in the second argument (which I left with '...' for now). </p>
  
  <p>Then I tried with sed, but got stuck after this:</p>
  
  <pre><code>echo "eh oh   37" | sed -e 's/\([0-9][0-9]\)/.../' 
  </code></pre>
  
  <p>Can I do arithmetic from <em>sed</em> using a reference to the matching digits and have the output not modify the number of spacing characters?</p>
  
  <p>Note that it's related to my question concerning Emacs and how to apply this to some (big) Emacs region (using a replace region with Emacs's <em>shell-command-on-region</em>) but it's not an identical question: this one is specifically about how to "keep spaces" when working with awk/sed/etc.</p>