#!/bin/sh # Auto generates stats article. echo "making stats" FILE_NAME="wiki_stats.md" printf "# LRS Wiki Stats\n\nThis is an autogenerated article holding stats about this wiki.\n\n" > $FILE_NAME printf -- "- number of articles: " >> $FILE_NAME ls *.md | wc -l >> $FILE_NAME printf -- "- number of commits: " >> $FILE_NAME git rev-list --count --all >> $FILE_NAME printf -- "- total size of all texts in bytes: " >> $FILE_NAME cat *.md | wc -c >> $FILE_NAME printf -- "- total number of lines of article texts: " >> $FILE_NAME cat *.md | wc -l >> $FILE_NAME printf -- "- number of script lines: " >> $FILE_NAME cat *.sh | wc -l >> $FILE_NAME printf "\nlongest articles:\n\n" >> $FILE_NAME ls -1hSs *.md | head -n 20 | sed "s/ *\([^ ]*\) \+\([^ ]*\)\.md/- [\2](\2.md): \1/g" >> $FILE_NAME printf "\n" >> $FILE_NAME printf "top 50 4+ letter words:\n\n" >> $FILE_NAME cat *.md | sed "$regex" | sed "$regex" | tr -cs "[:alpha:]" "\n" | \ sed -r "/^.{,3}$/d" | tr "A-Z" "a-z" | sort | uniq -c | sort -nr | \ head -n 50 | sed "s/ \+\([^ ]*\) \+\([^ ]*\)$/- \2 (\1)/g" >> $FILE_NAME printf "\n" >> $FILE_NAME printf "latest changes:\n\n\`\`\`\n" >> $FILE_NAME git log --name-only | head -n 50 | grep "Date:\|.*\.md" | sed "s/\([^ ]*\.md\)/ \1/g" >> $FILE_NAME printf "\`\`\`\n" >> $FILE_NAME printf "\nmost wanted pages:\n\n" >> $FILE_NAME ./most_wanted.sh >> $FILE_NAME printf "\n" >> $FILE_NAME