about summary refs log tree commit diff stats
path: root/trunk/hapaxlink.sh
diff options
context:
space:
mode:
Diffstat (limited to 'trunk/hapaxlink.sh')
-rw-r--r--trunk/hapaxlink.sh26
1 files changed, 26 insertions, 0 deletions
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 @@
1#!/bin/bash
2
3file="$1";
4headFile="$2";
5shift 2;
6glob="$@"; # *.hapax
7
8tempFile="${RANDOM}.tmp"
9
10echo -n "Linking \"$file\""
11# Begin
12cat "$headFile" > "$tempFile";
13echo -n "."
14# Link words to files they appear in
15for word in `sort "$file"`; do
16 f=`grep -liwq "^$word$" $glob`;
17 link="`basename $f .hapax`.html"
18 echo "[$word]($link)" >> "$tempFile";
19 echo -n "."
20done
21
22# Make the changes happen
23rm "$file"
24mv "$tempFile" "$file"
25
26echo "Done."