Created
May 30, 2021 20:50
-
-
Save marlluslustosa/84d615ad0e702f1085a5262b69016431 to your computer and use it in GitHub Desktop.
edit ranking script - marllus.com
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#marllus.com | |
cat export.txt | cut -d',' -f1 | sort | uniq -c | sort -r | egrep '\ \/(tecnologia|poesia|sociedade|arte)' | head -4 | sed 's/^\ *//g' | cut -d' ' -f2 | sed 's/^\/.*\///g ; s/\.html//g' > ranking_posts | |
cat export.txt | cut -d',' -f1,2 | sort | uniq -c | sort -r | egrep '\ \/(tecnologia|poesia|sociedade|arte)' | head -4 | sed 's/^\ .//g' | cut -d',' -f1,2 | sed 's/^\ *\([0-9]\+\)\ *.*html,\(.*$\)/- \2 (\1 views)/g' > ranking_posts_name | |
sed -i '1 i\Há uma mudança nos artigos em destaque. Segue a lista dos mais vistos:' ranking_posts_name | |
#remove previous featured in posts | |
find _posts/ -name "*.md" | xargs -n 1 sed -i '/^featured:\ true/d ; /^hidden:\ true/d ; /^rating:\ [1-5]\{1\}/d' | |
#add new param in featured posts | |
#featured: true | |
#hidden: true | |
#rating: a | |
a=5 | |
for i in `cat ranking_posts` | |
do | |
find _posts/ -name "*$i*" | xargs -n 1 sed -i '3 i featured: true\nhidden: true\nrating: '$a'' | |
((a--)) | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment