title: Create a dynamic header based from the output on the file (BASH)
body: <p>i have a file that is quite dynamic. Dynamic in a sense that <strong>Host</strong> and <strong>iSCSI_Name</strong> may come short or long. It works well for some host with long iqn name like the sample below but it doesn't work for host with shorter name.</p>
  <p>Would appreciate if someone had done this or maybe had a previous script that creates a dynamic header that follows the length on the given data or vice versa.</p>
  <p><strong>With long iqn name</strong></p>
  <pre><code>MAPPING
  ==================================================================================
  Host           Status                 iSCSI_Name                    State
  ==================================================================================
  irefr-esz-011  online  iqn.2000-01.com.vmware:irefr-esz-011-312901  active
  ==================================================================================
  </code></pre>
  <p><strong>with short iqn and host name</strong> output looks like this. Data is not in place.</p>
  <pre><code>MAPPING
  ==================================================================================
  Host           Status                 iSCSI_Name                    State
  ==================================================================================
  esz1  online  irefr-esz-011-312901  active
  ==================================================================================
  </code></pre>
  <p>Currently, i had this on my script.</p>
  <pre><code>echo -e &quot;\e[96m MAPPING\e[0m&quot;
  echo &quot;==================================================================================&quot;
  printf '%-12s %-30s %-21s %-30s %-20s\n' Host Status iSCSI_Name State
  echo &quot;==================================================================================&quot;
  
  cat outputfile | column -t
  
  echo &quot;==================================================================================&quot;
  echo
  </code></pre>
  <p>output file:</p>
  <pre><code>irefr-esz-011  online  iqn.2000-01.com.vmware:irefr-esz-011-312901  active
  esz1  online  irefr-esz-011-312901  active
  irefr-esz-011  online  iqn.2000-01.com.vmware:irefr-esz-011-312901  active
  esz1  online  irefr-esz-011-312901  active
  irefr-esz-011  online  iqn.2000-01.com.vmware:irefr-esz-011-312901  active
  esz1  online  irefr-esz-011-312901  active
  </code></pre>