mooc/filesystem/home/carole/A44/csvtohtml.sh

25 lines
659 B
Bash
Raw Normal View History

2023-01-31 08:45:52 +04:00
#!/bin/bash
if [ $# -eq 0 ] || [ ! -r "$1" ] ; then
echo "Usage : $0 file" >&2
exit 1
fi
echo -e "<html>\n<head>\n<meta charset=\"utf-8\" />\n</head>\n<style>
table { border-collapse:collapse; }
td { border-width:1px; border-style:solid; border-color:black; }
</style>\n<body>\n<table>"
IFS=',' ; # Internal Field Separator
while read line ; do
echo "<tr>"
set -- $line
for ((i=1 ; i <= $# ; i++)) ; do
echo "<td> ${!i} </td>"
done
echo "</tr>"
done < $1
echo -e "</table>\n</body>\n</html>"
exit 0
# https://www.w3schools.com/html/html_tables.asp
# http://css.mammouthland.net/tableaux-bordures-fines-border-css.php