title: Parse HTML table columns with bash
body: <p>I'm trying to extract 3 columns from a table in HTML. I need hostname, product + region and date added. So they would be columns 1, 3, 4. </p>
  
  <pre><code>&lt;div class="table sectionedit2"&gt;
    &lt;table class="inline"&gt;
      &lt;tr class="row0"&gt;
        &lt;th class="col0 centeralign"&gt;hostname&lt;/th&gt;
        &lt;th class="col1 centeralign"&gt;AKA (Client hostname)&lt;/th&gt;
        &lt;th class="col2 leftalign"&gt;Product + Region&lt;/th&gt;
        &lt;th class="col3 centeralign"&gt;date added&lt;/th&gt;
        &lt;th class="col4 centeralign"&gt;  decom. date  &lt;/th&gt;
        &lt;th class="col5 centeralign"&gt;           builder           &lt;/th&gt;
        &lt;th class="col6 centeralign"&gt;  build cross-checker  &lt;/th&gt;
        &lt;th class="col7 leftalign"&gt; &lt;strong&gt;decommissioner&lt;/strong&gt;&lt;/th&gt;
        &lt;th class="col8 centeralign"&gt;customer managed filesystems&lt;/th&gt;
        &lt;th class="col9 centeralign"&gt;  only company has root?  &lt;/th&gt;
      &lt;/tr&gt;
      &lt;tr class="row1"&gt;
        &lt;th class="col0 centeralign"&gt;HostName01&lt;/th&gt;
        &lt;td class="col1 leftalign"&gt;Host01&lt;/td&gt;
        &lt;td class="col2 leftalign"&gt;EU&lt;/td&gt;
        &lt;td class="col3 centeralign"&gt;2007-01-01&lt;/td&gt;
        &lt;td class="col4 leftalign"&gt;&lt;/td&gt;
        &lt;td class="col5 centeralign"&gt;Me&lt;/td&gt;
        &lt;td class="col6 centeralign"&gt;You&lt;/td&gt;
        &lt;td class="col7 leftalign"&gt;Builder01&lt;/td&gt;
        &lt;td class="col8 leftalign"&gt;xChecker01&lt;/td&gt;
        &lt;td class="col9 centeralign"&gt;yes&lt;/td&gt;
      &lt;/tr&gt;
     &lt;tr class="row2"&gt;
       &lt;th class="col0 centeralign"&gt;HostName02&lt;/th&gt;
       &lt;td class="col1 leftalign"&gt;Host02&lt;/td&gt;
       &lt;td class="col2 leftalign"&gt;U.S&lt;/td&gt;
       &lt;td class="col3 centeralign"&gt;2008-09-29&lt;/td&gt;
       &lt;td class="col4 leftalign"&gt;&lt;/td&gt;
       &lt;td class="col5 leftalign"&gt;Me01&lt;/td&gt;
       &lt;td class="col6 leftalign"&gt;You01&lt;/td&gt;
       &lt;td class="col7 leftalign"&gt;Builder02&lt;/td&gt;
       &lt;td class="col8 leftalign"&gt;xChecker02&lt;/td&gt;
       &lt;td class="col9 centeralign"&gt;yes&lt;/td&gt;
  </code></pre>
  
  <p>I want to get:</p>
  
  <pre class="lang-none prettyprint-override"><code>Hostname     Product + Region   Date added
  
  HostName01   EU                 2007-01-01
  
  HostName02   U.S                2008-09-29
  </code></pre>
  
  <p>Previously I tried stripping the HTML tags and using awk, although some of the columns in the table are empty. This means I didn't get colums 1, 3 and 4 for all the rows.</p>
  
  <p>I am trying to use:</p>
  
  <pre><code>xmllint --html --shell --format table.log &lt;&lt;&lt; "cat //table/tr/th/td[1]/text()"
  </code></pre>
  
  <p>This is giving me the second column, I tried "[0]" which doesn't work and I'm not sure how to get multiple columns at once.</p>