2 # Auto generates stats article.
6 FILE_NAME
="wiki_stats.md"
8 printf "# LRS Wiki Stats\n\nThis is an autogenerated article holding stats about this wiki.\n\n" > $FILE_NAME
10 printf -- "- number of articles: " >> $FILE_NAME
11 ls *.md |
wc -l >> $FILE_NAME
13 printf -- "- number of commits: " >> $FILE_NAME
14 git rev-list
--count --all >> $FILE_NAME
16 printf -- "- total size of all texts in bytes: " >> $FILE_NAME
17 cat *.md |
wc -c >> $FILE_NAME
19 printf -- "- total number of lines of article texts: " >> $FILE_NAME
20 cat *.md |
wc -l >> $FILE_NAME
22 printf -- "- number of script lines: " >> $FILE_NAME
23 cat *.sh |
wc -l >> $FILE_NAME
25 printf -- "- occurences of the word \"person\": " >> $FILE_NAME
26 grep -o -i "person[s \n\.,]" *.md |
wc -l >> $FILE_NAME
28 printf -- "- occurences of the word \"nigger\": " >> $FILE_NAME
29 grep -o -i "[^\[]nigger" *.md |
wc -l >> $FILE_NAME
31 printf "\nlongest articles:\n\n" >> $FILE_NAME
32 ls -1hSs *.md |
head -n 20 |
sed "s/ *\([^ ]*\) \+\([^ ]*\)\.md/- [\2](\2.md): \1/g" >> $FILE_NAME
33 printf "\n" >> $FILE_NAME
35 printf "top 50 5+ letter words:\n\n" >> $FILE_NAME
36 cat *.md |
sed "s/([^ ]\+\.md/ /g" |
tr -cs "[:alpha:]" "\n" | \
37 sed -r "/^.{,4}$/d" |
tr "A-Z" "a-z" |
sort |
uniq -c |
sort -nr | \
38 head -n 50 |
sed "s/ \+\([^ ]*\) \+\([^ ]*\)$/- \2 (\1)/g" >> $FILE_NAME
39 printf "\n" >> $FILE_NAME
41 printf "latest changes:\n\n\`\`\`\n" >> $FILE_NAME
42 git log
--name-only |
head -n 50 |
grep "Date:\|.*\.md" |
sed "s/\([^ ]*\.md\)/ \1/g" >> $FILE_NAME
43 printf "\`\`\`\n" >> $FILE_NAME
45 printf "\nmost wanted pages:\n\n" >> $FILE_NAME
47 cat .
/*.md |
sed -n 's/.*\[.*\](\([^\)\(]*\)).*/\1/p' |
sort |
uniq -c |
sort -nr > tmp.txt
52 while read -r line
; do
53 fname
=`echo "$line" | grep -o "[^ ]*\.md" -`
55 if ! [ -f $fname ]; then
56 printf -- "- [" >> tmp2.txt
57 printf $fname |
sed "s/^\([^ ]*\)\.md/\1](${fname}) (/g" >> tmp2.txt
58 echo $line |
sed "s/^ *\([0-9]*\).*$/\1)/g" >> tmp2.txt
62 cat tmp2.txt |
head -n 20 >> $FILE_NAME
65 printf "\nmost popular and lonely pages:\n\n" >> $FILE_NAME
71 count
=`grep -F -o "($fname)" *.md | wc -l`
72 echo "$count $fname" >> tmp.txt
77 cat tmp.txt |
sort -n -r |
head -n 30 > tmp2.txt
78 echo "- ..." >> tmp2.txt
79 cat tmp.txt |
sort -n -r |
tail -n 30 >> tmp2.txt
80 cat tmp2.txt |
sed "s/ *\([^ ]*\) \+\([^ ]*\)\.md/- [\2](\2.md) (\1) /g" >> $FILE_NAME
85 printf "\n" >> $FILE_NAME