Julius Plenz – Blog

sed and jekyll tags

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.


sed -s -n '
    /---/,/---/ {
        /tags:/ {
            s/^tags: \[//;
            s/, */\n/g;
    }' ~/blog/_posts/*.markdown | sort | uniq -c | sort -n

posted 2011-12-27 tagged sh and sed