#!/bin/sh function getTitle { cat "$1" \ |sed -n -e '/<[Tt][Ii][Tt][Ll][Ee]>.*<\/[Tt][Ii][Tt][Ll][Ee]>/p' \ |sed -e 's/ *<\/*[Tt][Ii][Tt][Ll][Ee]> *//g' } #getFile; function makeTitle { file="$1" title=`getTitle $file` if [ -z "$title" ] ; then title=`basename $file` fi echo "$title" } #makeTitle; cat <<EOF <html> <head> <title>Table of contents</title> </head> <body> <h1>Table of contents</h1> <ul> EOF for file in $@ ; do echo "$file "`makeTitle "$file"` done | sort +1 -t. +1n | while read file title ; do title=`echo "$title"|sed -e 's/\.\([0-9]\).html/ (\1)/'` echo '<li><a href="'"$file"'">'"$title"'</a>' done cat <<EOF </ul> </body> </html> EOF exit 0