Search form

Bash: Make a Web Site Index

An old Bash script that uses awk to construct an index with hyperlinks from the .html files in a web tree. Attempts to use the <title> tag to name each link.

To use, change your directories in the 'for dir' line to the directories you want to scan, then run the script: ./ > myfile.html.


for dir in html img inc home; do
    echo "
" newstring=$dir firstchar=${newstring:0:1} string1=${newstring:1} dirname=`echo $firstchar | tr '[a-z]' '[A-Z]'` echo "" echo "


" echo "
    " for file in `find $dir -name \*.html -print`; do #echo $file title=`awk 'BEGIN{IGNORECASE=1;FS="|";RS=EOF} {print $2}' $file` if [ -z "$title" ]; then title="NO TITLE! - $file" fi echo "
  • $title
  • " done echo "
" echo "
" done