title: AWK string/substring manipulations loses original formatting
body: <p>Hi I have the following file:</p>
  
  <pre><code>P:TWS.XAUUSD    07:34:47.872000 0       1306.73 1000    1306.87 500     0       0       99
  P:TWS.XAUUSD    07:34:47.876000 0       1306.7  500     1306.87 500     0       0       99
  P:TWS.XAUUSD    07:34:47.877000 0       1306.7  500     1306.85 500     0       0       99
  </code></pre>
  
  <p>I want to change the timestamp in the second column ($2) and reduce it by 1 hour.</p>
  
  <p>Im using awk, and split the 2nd field into 2 separate substrings, but when I use the following code:</p>
  
  <pre><code>awk '{print $1,substr($2,1,2)-1 substr($2,3,13),$3,$4,$5,$6,$7,$8,$9,$10}'
  </code></pre>
  
  <p>My output looks like this</p>
  
  <pre><code>P:TWS.XAUUSD 6:34:47.872000 0 1306.73 1000 1306.87 500 0 0 99
  P:TWS.XAUUSD 6:34:47.876000 0 1306.7 500 1306.87 500 0 0 99
  P:TWS.XAUUSD 6:34:47.877000 0 1306.7 500 1306.85 500 0 0 99
  </code></pre>
  
  <p>The calculation and information is correct, but I am losing the formatting (I require the hours HH column to be 2 digits).</p>
  
  <p>How can i perform the same calculation and keep the original formatting.  </p>
  
  <p>I tried to use the <em>printf</em> command, but then I cannot seem to extract multiple fields, and get the whole line that I need.</p>
  
  <blockquote>
    <p>awk '{printf ("%02d\n"),$2-1}'</p>
  </blockquote>
  
  <p>gives me the following output</p>
  
  <pre><code>06
  06
  06
  </code></pre>
  
  <p>How do I put the <em>print</em> and the <em>printf</em> together?</p>