#!/bin/bash
#                      /usr/local/bin/usr.share.doc-index
# http://crystalfaeries.net/posix/bin/usr.share.doc-index
# celeste:crystalfaery 2015-11-06 01:43:34+00:00
# from Linux Journal 2008 August Page 91 by Bill Zimmerly

input_dir=/usr/share/doc
output_file=/usr/share/doc/index.html

cat >$output_file <<EOF
<html>
<head>
<title>$input_dir</title>
</head>
<body>
EOF

find $input_dir -iname 'index.html' | sed 's/[^ ]*/\<br\>\<a href="file:&"\>&\<\/a\>/' | sort >> $output_file

cat >>$output_file <<EOF
</body>
</html>
EOF


syntax highlighted by Code2HTML, v. 0.9.1