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/backlink.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/backlink.sh')
-rw-r--r-- | trunk/backlink.sh | 29 |
1 files changed, 29 insertions, 0 deletions
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 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | # Command-line variables | ||
4 | searchQuery="$1"; # .html file to backlink | ||
5 | outFile="$2"; # .back file to create | ||
6 | headerFile="$3"; # header information file | ||
7 | shift 3; | ||
8 | glob="$@"; # where to search for backlinks | ||
9 | |||
10 | # Find backlinkers | ||
11 | echo -n "Back-linking \"$searchQuery\"" | ||
12 | cat "$headerFile" > "$outFile"; | ||
13 | grep -ql "$searchQuery" $glob >> "$outFile"; | ||
14 | |||
15 | # Change title of $outFile | ||
16 | inText="`basename $searchQuery .html`.txt"; | ||
17 | title=`grep '^title:' "$inText" | cut -d' ' -f2-`; | ||
18 | sed -i "s/_TITLE_/$title/" "$outFile"; | ||
19 | echo -n "." | ||
20 | |||
21 | # Link to backlinks | ||
22 | for file in `grep '.html' "$outFile"`; do | ||
23 | fText="`basename $file .html`.txt"; | ||
24 | title=`grep '^title:' $fText | cut -d' ' -f2-`; | ||
25 | sed -i "s/^$file$/- [$title](&)/" "$outFile"; | ||
26 | echo -n "." | ||
27 | done | ||
28 | |||
29 | echo "Done." | ||