less_retarded_wiki/make_stats.sh

42 lines
1.4 KiB
Bash
Raw Normal View History

2023-12-14 23:38:44 +01:00
#!/bin/sh
# Auto generates stats article.
echo "making stats"
FILE_NAME="wiki_stats.md"
2024-01-12 04:25:07 +01:00
printf "# LRS Wiki Stats\n\nThis is an autogenerated article holding stats about this wiki.\n\n" > $FILE_NAME
2023-12-14 23:38:44 +01:00
printf -- "- number of articles: " >> $FILE_NAME
ls *.md | wc -l >> $FILE_NAME
2024-01-24 18:11:37 +01:00
printf -- "- number of commits: " >> $FILE_NAME
git rev-list --count --all >> $FILE_NAME
2023-12-14 23:38:44 +01:00
printf -- "- total size of all texts in bytes: " >> $FILE_NAME
cat *.md | wc -c >> $FILE_NAME
2024-03-19 16:01:03 +01:00
printf -- "- total number of lines of article texts: " >> $FILE_NAME
cat *.md | wc -l >> $FILE_NAME
2023-12-14 23:38:44 +01:00
2024-03-19 16:01:03 +01:00
printf -- "- number of script lines: " >> $FILE_NAME
cat *.sh | wc -l >> $FILE_NAME
2023-12-14 23:38:44 +01:00
2024-03-19 16:01:03 +01:00
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
2024-01-07 03:16:15 +01:00
2024-03-19 16:01:03 +01:00
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
2023-12-14 23:38:44 +01:00
printf "\n" >> $FILE_NAME
2024-03-19 16:01:03 +01:00
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