diff options
author | Case Duckworth | 2015-04-01 23:16:18 -0700 |
---|---|---|
committer | Case Duckworth | 2015-04-01 23:20:18 -0700 |
commit | d161be120c22faf222ec15ca618ee367e4d56575 (patch) | |
tree | b945633e680e5682a967f63bad88a2b262b4d4c6 /trunk/hapaxlink.sh | |
parent | Merge branch 'gh-pages' of https://github.com/duckwork/autocento into gh-pages (diff) | |
download | autocento-d161be120c22faf222ec15ca618ee367e4d56575.tar.gz autocento-d161be120c22faf222ec15ca618ee367e4d56575.zip |
Refactor makefile; Add hapax preprocessor
Diffstat (limited to 'trunk/hapaxlink.sh')
-rw-r--r-- | trunk/hapaxlink.sh | 26 |
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 | |||
3 | file="$1"; | ||
4 | headFile="$2"; | ||
5 | shift 2; | ||
6 | glob="$@"; # *.hapax | ||
7 | |||
8 | tempFile="${RANDOM}.tmp" | ||
9 | |||
10 | echo -n "Linking \"$file\"" | ||
11 | # Begin | ||
12 | cat "$headFile" > "$tempFile"; | ||
13 | echo -n "." | ||
14 | # Link words to files they appear in | ||
15 | for 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 "." | ||
20 | done | ||
21 | |||
22 | # Make the changes happen | ||
23 | rm "$file" | ||
24 | mv "$tempFile" "$file" | ||
25 | |||
26 | echo "Done." | ||