Saturday, October 18, 2008

Bash: Generate an HTML table

#!/bin/bash
clear
typeset -i row col rows cols
let row=1 col=1 rows=10 cols=10

echo "<table>";
 while ((row<=rows)) ; do
          echo -n "<tr>"
          while ((col<=cols)) ; do
                echo -n "<td>";
                echo -n $col;
                echo -n "</td>";
                let col++
               done
 let col=1
 echo "</tr>";
 let row++
 done
echo "</table>";

No comments: