about summary refs log tree commit diff stats
path: root/trunk/common-titles.sh
blob: 9bc0de8d31828ffebe75a29592a116d73d466ac9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/bash

outFile="$1";
header="$2";
shift 2;
glob="$@";

echo -n "Compiling ${outFile}...";
cat "$header" > $outFile;

for file in $glob; do
    # Copy title to $outFile & link
    title="$(grep '^title:' "$file" | cut -d' ' -f2- | sed 's/"//g')";
    if (( $RANDOM % 13 == 0 )); then
        echo -n "| ";
    else
        echo -n "  ";
    fi
    echo "[$title](${file%.*}.html)" >> "$outFile";
done
echo "Done.";