about summary refs log tree commit diff stats
path: root/trunk/backlink.sh
diff options
context:
space:
mode:
Diffstat (limited to 'trunk/backlink.sh')
-rw-r--r--trunk/backlink.sh29
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
4searchQuery="$1"; # .html file to backlink
5outFile="$2"; # .back file to create
6headerFile="$3"; # header information file
7shift 3;
8glob="$@"; # where to search for backlinks
9
10# Find backlinkers
11echo -n "Back-linking \"$searchQuery\""
12cat "$headerFile" > "$outFile";
13grep -ql "$searchQuery" $glob >> "$outFile";
14
15# Change title of $outFile
16inText="`basename $searchQuery .html`.txt";
17title=`grep '^title:' "$inText" | cut -d' ' -f2-`;
18sed -i "s/_TITLE_/$title/" "$outFile";
19echo -n "."
20
21# Link to backlinks
22for 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 "."
27done
28
29echo "Done."