Commit | Line | Data |
---|---|---|
6fe00273 SK |
1 | #! /bin/sh |
2 | ||
3 | case "$1" in | |
4 | '') N=10;; | |
5 | *) N="$1" | |
6 | esac | |
7 | ||
8 | grep -a 'player: *played' "$FILE_LOG_MPD" \ | |
9 | | awk ' | |
10 | BEGIN { | |
11 | s = " *" | |
12 | } | |
13 | ||
14 | $5 == "player:" && $6 == "played" { | |
15 | sub("^" s $1 s $2 s $3 s $4 s $5 s $6 s, "") | |
16 | count[$0]++ | |
17 | } | |
18 | ||
19 | END { | |
20 | for (song in count) | |
21 | printf("%d %s\n", count[song], song) | |
22 | }' \ | |
23 | | sort -n -k 1 -r \ | |
24 | | head -"$N" |