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/backlink.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 trunk/backlink.sh (limited to 'trunk/backlink.sh') diff --git a/trunk/backlink.sh b/trunk/backlink.sh new file mode 100644 index 0000000..7d143a8 --- /dev/null +++ b/trunk/backlink.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +# Command-line variables +searchQuery="$1"; # .html file to backlink +outFile="$2"; # .back file to create +headerFile="$3"; # header information file +shift 3; +glob="$@"; # where to search for backlinks + +# Find backlinkers +echo -n "Back-linking \"$searchQuery\"" +cat "$headerFile" > "$outFile"; +grep -ql "$searchQuery" $glob >> "$outFile"; + +# Change title of $outFile +inText="`basename $searchQuery .html`.txt"; +title=`grep '^title:' "$inText" | cut -d' ' -f2-`; +sed -i "s/_TITLE_/$title/" "$outFile"; +echo -n "." + +# Link to backlinks +for file in `grep '.html' "$outFile"`; do + fText="`basename $file .html`.txt"; + title=`grep '^title:' $fText | cut -d' ' -f2-`; + sed -i "s/^$file$/- [$title](&)/" "$outFile"; + echo -n "." +done + +echo "Done." -- cgit 1.4.1-21-gabe81