title: How to convert text file data into html table format in linux shell scripting
body: <p>I want to convert samplefile.txt  into  html table format.It should ignore all special characters.The start of char <code>###</code> must go into table header,while  the contents inside table header into table cell.</p>
  
  <p>Also I want to format table heading and table border in this script.</p>
  
  <p>This is a simple samplefile.txt:</p>
  
  <pre><code>###File1
  ###File2
  ###File3
  ###Sports
  Y|Cricket|Football|basketball
  Y|beach volleyball|boxing|diving
  Y|cycling|Batminton|Swimming
  ###Country
  $|United States|United Kingdom|India    
  $|Peru|Japan|Poland
  </code></pre>
  
  <p>This is the script I have been working in - Somehow this code is not working 100%:</p>
  
  <pre><code>#!/bin/sh
  tableflag=0
  echo "&lt;html&gt;"
  echo "&lt;body&gt;"
  while read line
  do
  #echo $line
  heading=`echo $line | cut -c-3`
  headdata=`echo $line | cut -c4-`
  if [ "$heading" == "###" ]; then
          #if [ $tableflag -eq 1 ]; then
                  #echo "&lt;/table&gt;"
          #fi
          echo "&lt;th colspan="3" style="font-family: 'Times New Roman';"&gt; $headdata &lt;/th&gt;"
          echo '&lt;tr&gt;  &lt;/tr&gt;'
          echo '&lt;table border="1" style="width:80%;margin:30px"&gt;'
  else
          tableflag=1
          echo '&lt;tr&gt;'
          echo "$line" | awk -F"|" '{print "&lt;td&gt;" $2 "&lt;/td&gt;&lt;td&gt;" $3"&lt;/td&gt;&lt;td&gt;"$4"&lt;/td&gt;"}'
          echo '&lt;/tr&gt;'
          echo '&lt;tr&gt; &lt;/tr&gt;'
  
  fi
  done &lt; samplefile.txt 
  echo "&lt;/table&gt;"
  echo "&lt;/body&gt;"
  echo "&lt;/html&gt;"
  </code></pre>