title: table formatted output with printf
body: <p>I try to create a formatted output with printf. But I can't align output as I wish. My code is like below:</p>
  
  <pre><code>#!/bin/bash
  header="%-10s %8s %13s %15s %3s\n"
  format="%-10s %8s %13s %15s %3s\n"
  
  lvalue1="10000000000"
  rvalue1="10000000000"
  
  lvalue2="20000000000"
  rvalue2="20000000000"
  
  lvalue3="10000"
  rvalue3="10000"
  
  lvalue4="300000000"
  rvlaue4="300000000"
  
  lvalue5="2000"
  rvalue5="2000"
  
  value6="1500"
  
  value7="2200"
  
  lvalue8="2300"
  rvalue8="2300"
  
  
  formula1="formula1"
  formula2="formula2"
  formula3="formula3"
  formula4="formula4"
  formula5="formula5"
  formula6="formula6"
  formula7="formula7"
  formula8="formula8"
  
  check1="Total Received Packets"
  check2="Total Transmitted Packets"
  check3="Packets Lost"
  check4="Media Access Control Address"
  check5="IPv4 Default Gateway"
  check6="Input Rate (bits/sec)"
  check7="Output Rate (bits/sec)"
  check8="Ignored Packets"
  
  
  printf "$header" "CHECK" "FORMULA" "LVALUE" "RVALUE" "PASSED"
  printf "$format" \
  "$check1" "$formula1" "$lvalue1" "$rvalue1" "y/n" \
  "$check2" "$formula2" "$lvalue2" "$rvalue2" "y/n" \
  "$check3" "$formula3" "$lvalue3" "$rvalue3" "y/n" \
  "$check4" "$formula4" "$lvalue4" "$rvalue4" "y/n" \
  "$check5" "$formula5" "$lvalue5" "$rvalue5" "y/n" \
  "$check6" "$formula6" "$value6" "              " "y/n" \
  "$check7" "$formula7" "$value7" "              " "y/n" \
  "$check8" "$formula8" "$lvalue8" "$rvalue8" "y/n"
  </code></pre>
  
  <p>And output looks like:</p>
  
  <pre><code>CHECK       FORMULA        LVALUE          RVALUE PASSED
  Total Received Packets formula1   10000000000     10000000000 y/n
  Total Transmitted Packets formula2   20000000000     20000000000 y/n
  Packets Lost formula3         10000           10000 y/n
  Media Access Control Address formula4     300000000                 y/n
  IPv4 Default Gateway formula5          2000            2000 y/n
  Input Rate (bits/sec) formula6          1500                 y/n
  Output Rate (bits/sec) formula7          2200                 y/n
  Ignored Packets formula8          2300            2300 y/n
  </code></pre>
  
  <p>And as you see, fields are not aligned correctly. So where should I modify to have a better look for this table?</p>
  
  <p>Thanks</p>