A couple one-liners

metalcrowe on 2006-01-30T08:37:30

These are probably stupid-simple-obvious, but I find them useful enough that they made it into little scripts in ~/bin.

unique

perl -ne'print unless $lines{$_}++'

Only print the first occurance of a line. This one came about recently when I wanted to find out which of my ripped albums were 128kbps mp3s (so I could re-rip them!):

mp3find ~/cds -bitrate 128 -printf '%b' | unique

qm

perl -pe'chomp;$_=quotemeta($_)."\n"'

This one comes in handy when using xargs to pipe a bunch of mp3 filenames with spaces in them to something like madplay or BMP.

nocomment

perl -pe's/(^|\s)#.*//;'

Dumb comment stripper. Again useful for piping M3U lists to madplay:

nocomment ilyaimy.m3u | qm | xargs madplay