#! /bin/bash
# Create HTML table / usage [-d] FILES..
#
DCHAR=","
while getopts :hd: n
do
case $n in
d) DCHAR=$OPTARG ;;
h) cat <<"EOF" >&2
$0 [-h][-d DELIMITER_CHAR ] FILES...
EOF
exit 0
;;
?) echo " unkown $n" ;;
esac
done
let n=OPTIND-1
shift $n
gawk -F"$DCHAR" 'BEGIN{
print ""
}
function line()
{
print ""
for(i=1;i<=NF;i=i+1) printf "<%s>%s%s>\n",
tag, $i, tag
print "
"
}
{
if (NR==1) tag="th"
else tag="td"
line()
}END{
print "
"
}' $*