Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

metalcrowe (5600)

  (email not shown publicly)
AOL IM: metalcrowe (Add Buddy, Send Message)

Journal of metalcrowe (5600)

Monday January 30, 2006
03:37 AM

A couple one-liners

[ #28515 ]

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


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


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.


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

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

nocomment ilyaimy.m3u | qm | xargs madplay

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.