# ls-l2html.awk	juvaste@cs.joensuu.fi
# make an html page out of a ls -l listing

# header stuff
BEGIN {
	printf "<HTML>\n<HEAD>\n<TITLE>Hakemiston ";
	system("pwd | awk -F/ ' { printf \"%s \", $NF } ' ");
	printf "listaus</TITLE>\n</HEAD>\n<BODY>\n";

	printf "<H1>Hakemiston ";
	system("pwd | awk -F/ ' { printf \"%s \", $NF } ' ");
	printf "listaus</H1>\n";
	printf "Päivitetty ";
	system("date");
	printf "<BR>\n"
	printf "<BR>\n"
}

# skip short lines
NF < 7 { next; }

# skip this file
$NF == "ls-l2html.awk" { next; }

# skip index.htm
$NF == "index.htm" { next; }

# skip index.html
$NF == "index.html" { next; }

# actual printing
{	printf "<A HREF=\"%s\">%s</A> &#160; &#160; &#160; <HT> (%s %s)<BR>\n", $NF, $NF, $5, $6; }

# end stuff
END {
	printf "<!-- ls-l2html.awk juvaste@cs.joensuu.fi -->\n";
	printf "</BODY>\n</HTML>\n";
}

