#!/bin/bash # # linktree -- 2008-09-15 # # Make a link tree for the current directory, creates linktree.html # for inclusion in index.html with this SSI directive: # # # # Linktree lines are padded with " " (two blanks) and include the #
 formatting tags.
#
# Copyright (C) 2008 Grant Coady  GPLv2
#
# Call: cd $some_dir; linktree
#
# Excludes listing of index.html and README.html files as well as the 
#  linktree output file as well as other file areas, adjust to taste :)
#
# Limited to 2 directory levels
#

tree -L 2 -n -I "README*|index*|linktree*" --noreport	| \
	egrep -v '/usr/local|/home/common|\.txt\.gz'	| \
	awk -v dir="$1" '
	BEGIN {
		print ""
	}
	FNR == 1 {
		print "
  " $1
		next
	}
	!/^ / && /^.-- / {
		printf "  %s %s\n", $1, $2, $2
		dir = $2
		next
	}
	{
		link = sprintf("%s", dir, $NF, $NF)
	}
	!/^ / && /^|   .-- / {
		print "  " $1, "  " $2, link
	}
	/^    .-- / {
		print "     ", $1, link
	}
	END {
		print "
" } ' > linktree.text # end