I’m learning more about powerful tools like sed and awk while taking a break from my task management app project. One-liners are great for many reasons – they’re easy to stick in your .bashrc or .zshrc file as aliases or to incorporate into functions.

This particular one-liner simply traverses a music directory, organized as Artist/Album/Songs, and dumps it out in a pretty list.

c d ~ / M u s i c & & f i n d . \ ! - n a m e " . * " | s e d - E e ' s / [ 0 - 9 ] { 2 } / g ' - E e ' s / \ . ( m 4 a | m p 3 ) $ / / g ' | a w k - F / ' N F > 0 { f o r ( i = 2 ; i < N F ; i + + ) { p r i n t f " " } p r i n t $ N F } '

Here’s a snippet of what the output looks like:

...
Phoenix
    Wolfgang Amadeus Phoenix
        Lisztomania
        1901
        Fences
        Love Like A Sunset Part I
        Love Like A Sunset Part II
        Lasso
        Rome
        Countdown
        Girlfriend
        Armistice
R.E.M.
    Reveal
        The Lifting
        I've Been High
        All The Way To Reno (You're Gonna Be A Star)
...