about summary refs log tree commit diff stats
path: root/trunk/first-lines.sh
blob: 50b0e0cb832685d14fb0ab7ca9906695161a191e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/bin/bash

outFile=src/first-lines.txt

echo "" > $outFile

for file in src/*.txt; do
    echo -n "Getting first line of $file .. "
    endOfYAML=$(sed -n '/^\.\.\.$/=' "$file")
    firstLineNumber=$((endOfYAML + 2))

    echo "$file: " >> $outFile
    echo "      $(head -n $firstLineNumber "$file" | tail -n 1)" >> $outFile

    unset endOfYAML firstLineNumber
    echo "Done."
done