alexkarle.com

Source for alexkarle.com
git clone git://git.alexkarle.com/alexkarle.com.git
Log | Files | Refs | README | LICENSE

commit f1e3c604e95a1cd2150a792fbe1756939c3d5898 (patch)
parent 5cb76f66f866a8b50ddcc33c0c996bfc16703104
Author: Alex Karle <alex@alexkarle.com>
Date:   Wed, 21 Apr 2021 00:31:23 -0400

jam-tuesday: Add rollup counts to stats.sh

I'm having way too much fun here... :)

Diffstat:
Mjam-tuesday/03-30-21 | 4++--
Mjam-tuesday/04-13-21 | 2+-
Mjam-tuesday/stats.sh | 35++++++++++++++++++++++++++++++-----
3 files changed, 33 insertions(+), 8 deletions(-)

diff --git a/jam-tuesday/03-30-21 b/jam-tuesday/03-30-21 @@ -8,7 +8,7 @@ the time we did, I had the bass line _down_ and it slaps! --- -Lost in My Mind, Head and the Heart +Lost in My Mind, The Head and The Heart Shadow People, Dr. Dog Walden Pond, Atta Boy Rhode Island, The Front Bottoms @@ -22,7 +22,7 @@ Chameleon, Herbie Hancock (Bass) Twin Size Mattress, The Front Bottoms Original, Matt Jack and Blow, Atta Boy -Rivers and Roads, Head and the Heart +Rivers and Roads, The Head and The Heart Jack and Blow (reprise), Atta Boy The Two of Us, Omar Apollo (Bass) diff --git a/jam-tuesday/04-13-21 b/jam-tuesday/04-13-21 @@ -15,7 +15,7 @@ The Two of Us, Omar Apollo (Bass) Talk to the Moon, Ripe Twin Size Mattress, The Front Bottoms (Reprise) When it Rains it Poors, Twiddle -Honeybee, Head and the Heart +Honeybee, The Head and The Heart No Such Thing, John Mayer Twin Size Mattress, The Front Bottoms (Reprise) With a Little Help From My Friends, The Beatles diff --git a/jam-tuesday/stats.sh b/jam-tuesday/stats.sh @@ -1,21 +1,46 @@ #!/bin/sh # stats.sh -- get frequencies of jam-tuesday songs/artists set -e + +N=${1:-10} DIR=$(dirname "$0") TMP=$(mktemp) for set in "$DIR"/[01][0-9]-*; do # Remove leading notes, blank lines, and instrument/reprise # comments (and blank lines before or after the comments) - sed '1,/---/d' "$set" | grep -v '^ *$' | sed 's/ *([^)]*) *//' + sed '1,/---/d' "$set" | grep -v '^ *$' | sed 's/ *([^)]*) *//g' done > "$TMP" -echo "Top 10 Artists (Frequency, Name):" +artists() { + sed 's/.*, *//' "$TMP" | sort -f | uniq -i -c +} + +songs() { + sort -f "$TMP" | uniq -i -c +} + +topN() { + sort -n -r | head -n "$N" +} + +count() { + wc -l | cut -d' ' -f 1 +} + +echo "Play Stats:" +echo "-----------" +printf "%7d Songs Total\\n" "$(count < "$TMP")" +printf "%7d Unique Songs\\n" "$(songs | count)" +printf "%7d Unique Artists\\n\\n" "$(artists | count)" + +echo "Top $N Artists (Frequency, Name):" echo "---------------------------------" -sed 's/.*, *//' "$TMP" | sort -f | uniq -i -c | sort -n -r | head -n 10 +artists | topN echo "" -echo "Top 10 Songs (Frequency, Name):" +echo "Top $N Songs (Frequency, Name):" echo "-------------------------------" -sort -f "$TMP" | uniq -i -c | sort -n -r | head -n 10 +songs | topN + rm "$TMP"