From f1e3c604e95a1cd2150a792fbe1756939c3d5898 Mon Sep 17 00:00:00 2001 From: Alex Karle Date: Wed, 21 Apr 2021 00:31:23 -0400 Subject: [PATCH] jam-tuesday: Add rollup counts to stats.sh I'm having way too much fun here... :) --- jam-tuesday/03-30-21 | 4 ++-- jam-tuesday/04-13-21 | 2 +- jam-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 index e7bcb73..62d5a38 100644 --- 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 index a6e8785..8d62df4 100644 --- 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 index 8763b5a..4b44cf8 100755 --- 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" -- libgit2 1.1.1