[ murray.saul ] cat grade.dat
IOS110;70
OPS435;90
ICA001;5
[ murray.saul ] cat makeTable.bash
#!/bin/bash
if [ $# -ne 2 ]
then
echo "USAGE: $0 [input-file][webpage-file]" >&2
exit 1
fi
if [ ! -f $1 ]
then
echo "Error: The file pathname \"$1\" does not exist" >&2
exit 1
fi
cat > ~/public_html/$2 <<+
My Demo
Here is the table:
+
awk -F";" 'BEGIN {print "COURSE | GRADE |
---|
";OFS=" | "} {if (NR <= 2) {ORS=" |
"} else {ORS=""};print $1,$2} END {print " |
"}' $1 >> ~/public_html/$2
cat >> ~/public_html/$2 <<+
+
[ murray.saul ] ./makeTable.bash
USAGE: ./makeTable.bash [input-file][webpage-file]
[ murray.saul ] echo $?
1
[ murray.saul ] ./makeTable.bash moo.dat table.html
Error: The file pathname "moo.dat" does not exist
[ murray.saul ] echo $?
1
[ murray.saul ] ./makeTable.bash grade.dat table.html
[ murray.saul ] cat ~/public_html/table.html
My Demo
Here is the table:
COURSE | GRADE |
---|
IOS110 | 70 |
OPS435 | 90 |
ICA001 | 5 |
[ murray.saul ]