less_retarded_wiki/most_wanted.sh

21 lines
526 B
Bash
Raw Normal View History

2024-01-07 03:16:15 +01:00
#!/bin/sh
2024-03-19 16:01:03 +01:00
# Outputs a list of most wanted pages. Takes a while to finish.
2024-01-07 03:16:15 +01:00
2024-03-19 16:01:03 +01:00
cat ./*.md | sed -n 's/.*\[.*\](\([^\)\(]*\)).*/\1/p' | sort | uniq -c | sort -nr > tmp.txt
2024-01-07 03:16:15 +01:00
rm tmp2.txt
touch tmp2.txt
while read -r line; do
2024-03-19 16:01:03 +01:00
fname=`echo "$line" | grep -o "[^ ]*\.md" -`
if ! [ -f $fname ]; then
printf -- "- [" >> tmp2.txt
printf $fname | sed "s/^\([^ ]*\)\.md/\1](${fname}) (/g" >> tmp2.txt
echo $line | sed "s/^ *\([0-9]*\).*$/\1)/g" >> tmp2.txt
2024-01-07 03:16:15 +01:00
fi
done < tmp.txt
cat tmp2.txt | head -n 20
2024-03-19 16:01:03 +01:00
rm tmp.txt tmp2.txt