Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # fisiere de intrare
- PLAYLISTURI="*-*.txt"
- # fisiere de iesire
- FISIER_CLASAMENT="clasament.txt"
- echo -n "Inlocuire \' cu '... "
- sed -i "s/\\\'/\'/g" $PLAYLISTURI
- echo "OK"
- echo -n "Inlocuire 'Roak My Life' cu 'Rock My Life'... "
- sed -i "s/Roak My Life/Rock My Life/g" $PLAYLISTURI
- echo "OK"
- NR_CLASAMENTE=`ls $PLAYLISTURI | wc -l`
- NR_PIESE=`grep -E -h "^\s+[0-9]+\.\s+" $PLAYLISTURI | cut -c 11- | sort | uniq | wc -l`
- echo
- echo "Numar de clasamente saptamanale: $NR_CLASAMENTE"
- echo "Numar total de piese unice: $NR_PIESE"
- echo
- echo -n "Scriere fisier '$FISIER_CLASAMENT'... "
- cat <<EOT > $FISIER_CLASAMENT
- # ARTIST TITLU PUNCTAJ
- =========================================================================================
- EOT
- grep -E -h "^\s+[0-9]+\.\s+" $PLAYLISTURI | tr -d '\r' | sed -E "s/^\s+//; s/\.\s+/\//; s/ \/ /\//" |
- awk 'BEGIN { FS=OFS=SUBSEP="/" } { h[$2, $3] += 51-$1 } END { for (i in h) print h[i], i }' |
- sort -t "/" -k1nr,1 -k2 | awk -F "/" '{ printf "%3d %-32s %-48s %3d\n", NR, $2, $3, $1 }' >> $FISIER_CLASAMENT
- echo "OK"
- #~ Inlocuire \' cu '... OK
- #~ Inlocuire 'Roak My Life' cu 'Rock My Life'... OK
- #~ Numar de clasamente saptamanale: 40
- #~ Numar total de piese unice: 217
- #~ Scriere fisier 'clasament.txt'... OK
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement