From d161be120c22faf222ec15ca618ee367e4d56575 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Wed, 1 Apr 2015 23:16:18 -0700 Subject: Refactor makefile; Add hapax preprocessor --- trunk/hapaxlink.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 trunk/hapaxlink.sh (limited to 'trunk/hapaxlink.sh') diff --git a/trunk/hapaxlink.sh b/trunk/hapaxlink.sh new file mode 100644 index 0000000..286c43d --- /dev/null +++ b/trunk/hapaxlink.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +file="$1"; +headFile="$2"; +shift 2; +glob="$@"; # *.hapax + +tempFile="${RANDOM}.tmp" + +echo -n "Linking \"$file\"" +# Begin +cat "$headFile" > "$tempFile"; +echo -n "." +# Link words to files they appear in +for word in `sort "$file"`; do + f=`grep -liwq "^$word$" $glob`; + link="`basename $f .hapax`.html" + echo "[$word]($link)" >> "$tempFile"; + echo -n "." +done + +# Make the changes happen +rm "$file" +mv "$tempFile" "$file" + +echo "Done." -- cgit 1.4.1-21-gabe81