title: How to preserve spaces when outputting a shell variable?
body: <p>For string matching purposes I need to define a bash variable with leading spaces.
  I need to define this starting from an integer, like:</p>
  
  <pre><code>jj=5
  </code></pre>
  
  <p>printf seems to me a good idea, so if I want to fill spaces up to 6 character:</p>
  
  <pre><code>jpat=`printf "  %6i"  $jj`
  </code></pre>
  
  <p>but unluckly when I am trying to recall the variable:</p>
  
  <pre><code>echo $jpat
  </code></pre>
  
  <p>the leading whitespaces are removed and I only get the <code>$jj</code> integer as it was.</p>
  
  <p>Any solution to keep such spaces?</p>
  
  <p>(This is equivalent to this: <code>v='  val'; echo $v$v</code>. Why aren't there leading and multiple spaces in output?)</p>