-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathstats.sh
More file actions
executable file
·29 lines (23 loc) · 967 Bytes
/
stats.sh
File metadata and controls
executable file
·29 lines (23 loc) · 967 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#! /bin/bash
numdefs=$(
cat README.md | awk '
BEGIN{count=0; content=1}
/<!--/{content=0}
/<DT>/ && content{count++}
/<DT>.*name=.*href=#contents/ && content{count--}
/<DT>.*<DT>/ && content{print "Warning: Two DT tags on the same line (" NR ")" > "/dev/stderr" }
/<DD>.*<DD>/ && content{print "Warning: Two DD tags on the same line (" NR ")" > "/dev/stderr" }
/-->/{content=1}
END{print count}
' )
# README.md might be a symlink. We have to avoid overwriting that,
# so do not do sed in place!
if true; then
tmpfile=`mktemp`
cat README.md > $tmpfile
# cat $tmpfile | sed '/A glossary of[0-9 ]\+.*data management acronyms and terms/s/\(A glossary of\)[0-9 ]\+\(\(environmental \)\?data management terms\)/\1 '$numdefs' \2/' > README.md
cat $tmpfile | sed '/\[\](number of entries) [0-9 ]\+/s/\(\[\](number of entries)\)[0-9 ]\+/\1 '$numdefs'/' > README.md
rm $tmpfile
fi
>&2 echo Found $numdefs definitions
# vim: se nowrap tw=0 :