summaryrefslogtreecommitdiff
path: root/dirindex.sh
diff options
context:
space:
mode:
Diffstat (limited to 'dirindex.sh')
-rwxr-xr-xdirindex.sh22
1 files changed, 22 insertions, 0 deletions
diff --git a/dirindex.sh b/dirindex.sh
new file mode 100755
index 0000000..127a4c0
--- /dev/null
+++ b/dirindex.sh
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+t=`echo $1 | sed -e 's/.*\/\([^\/]*\)/\1/' -e 's/^./\U&/g'`
+echo "$t"
+echo "======================================================================="
+echo ""
+
+# list of files sorted by modtime
+find $1 -type f -name '*.txt' ! -name 'index.*' -printf '%T@ %p\n' \
+| sort -r -n | awk '{print $2}' | while read f; do
+ reluri=`echo $f | sed 's/.*\/\([^\/]*\)\.txt/\1/'`
+ title=`sed -e 's/# //' -e 1q < $f`
+
+ echo -n "- [$title]($reluri)"
+ if test `grep -c '^### ' < $f` -ne 0; then
+ subtitle=`sed -e 's/### //' -e 4q < $f | tail -n 1`
+ echo -n ": $subtitle"
+ fi
+ echo ""
+done
+
+exit 0