about summary refs log tree commit diff stats
path: root/trunk/first-lines.sh
diff options
context:
space:
mode:
authorCase Duckworth2015-04-02 17:34:26 -0700
committerCase Duckworth2015-04-02 17:34:26 -0700
commitbd9abbe4eb94b9c77865bd28bf73ec6eb0b39a95 (patch)
treeebfeb8135d5610aac69b8938d4dab09b23b758e2 /trunk/first-lines.sh
parentRefactor makefile; Add hapax preprocessor (diff)
downloadautocento-bd9abbe4eb94b9c77865bd28bf73ec6eb0b39a95.tar.gz
autocento-bd9abbe4eb94b9c77865bd28bf73ec6eb0b39a95.zip
Fix #15: add compile support for indeces
Diffstat (limited to 'trunk/first-lines.sh')
-rw-r--r--trunk/first-lines.sh32
1 files changed, 21 insertions, 11 deletions
diff --git a/trunk/first-lines.sh b/trunk/first-lines.sh index 50b0e0c..37b7291 100644 --- a/trunk/first-lines.sh +++ b/trunk/first-lines.sh
@@ -1,17 +1,27 @@
1#!/bin/bash 1#!/bin/bash
2 2
3outFile=src/first-lines.txt 3outFile="$1";
4header="$2";
5shift 2;
6glob="$@";
4 7
5echo "" > $outFile 8firstLineOf() { # $1 = file
9 endOfYaml=$(sed -n '/^\.\.\.$/=' "$1")
10 tryLineNumber=$((endOfYaml + 1))
11 try=""
12 while [[ -z $try ]]; do
13 try=$(head -n $tryLineNumber "$1" | tail -n 1 |\
14 sed -e 's/^[|>] //' -e 's/[][]//g' -e 's/^#.*//' -e 's/^--.*//')
15 (( tryLineNumber += 1 ))
16 done
17 echo "$try"
18}
6 19
7for file in src/*.txt; do 20echo -n "Compiling ${outFile}..."
8 echo -n "Getting first line of $file .. " 21cat "$header" > $outFile
9 endOfYAML=$(sed -n '/^\.\.\.$/=' "$file")
10 firstLineNumber=$((endOfYAML + 2))
11 22
12 echo "$file: " >> $outFile 23for file in $glob; do
13 echo " $(head -n $firstLineNumber "$file" | tail -n 1)" >> $outFile 24 # Copy first line to $outFile & link
14 25 echo "[$(firstLineOf "$file")](${file%.*}.html)" >> $outFile
15 unset endOfYAML firstLineNumber
16 echo "Done."
17done 26done
27echo "Done."