#!/bin/csh -f

# Copies standard input to standard output, with lines of input coming
# out as entries of HTML table rows using $1 columns per row (default
# 6).  Uses $2 as an insertion between columns (default empty string);
# another option could be a dummy column containing nonbreaking space.
# Width of each column is $3; else unspecified in generated html.

set numcols = 6
set intercol = ""
set colwidth = ""

if ($#argv >= 1) set numcols = $1
if ($#argv >= 2) set intercol = "$2"
if ($#argv >= 3) set colwidth = " width=$3"

echo "<tr>"
awk 'NR>1 {if (NR%'$numcols'==1) print " </tr>\n\n<tr>"; else printf "'"$intercol"'"}\
     {print " <td""'"$colwidth"'"">"$0"</td>"}'
echo " </tr>"
