title: linux shell script printf number format color
body: <p>Ahead, Sorry for my english sentence. ( I am weak at English )</p>
  
  <p>Here is a source.<br/>
  I wanna color the ${test} in %d %f format.<br/>
  But I get an error. Invalid number.</p>
  
  <p>I wanna maintain %d %f format ( for comma and point ) and also want the color.<br/>
  Please, know the way.</p>
  
  <p>source</p>
  
  <pre><code>#!/bin/sh
  warning_color=$(tput setaf 4) # blue
  end_color=$(tput sgr0)
  
  test="30000"
  result="30000"
  if [[ ${test} -gt 20000 ]]
  then
    test="${warning_color}${test}${end_color}"
  fi
  printf "%'10d%'10d\n" "${test}" "${result}"
  
  test="30000.13"
  result="30000.13"
  if [[ ${test%%.*} -gt 20000 ]]
  then
    test="${warning_color}${test}${end_color}"
  fi
  printf "%'10.2f%'10.2f\n" "${test}" "${result}"
  </code></pre>
  
  <p>error ( 30000 and 30000.13 color is blue in error message )</p>
  
  <pre><code>a.sh: line 7: printf: 30000: invalid number
       0a.sh: line 11: printf: 30000.13: invalid number
    0.00
  </code></pre>