Did you know the -s switch to sed? I had the strange effect that
operating on several files produced different results between when I
called sed repeatedly in a for loop and passing all the files as
arguments just once. – -s tells sed not to consider all
files to be one big stream, but to separate them from each other.
Anyway, here's a script that searches all the posts now and gives me numbers on the tags I already used.
#!/bin/sh
sed -s -n '
/---/,/---/ {
/tags:/ {
s/^tags: \[//;
s/\]$//;
s/, */\n/g;
p
}
}' ~/blog/_posts/*.markdown | sort | uniq -c | sort -n