next up previous
Next: Tips, Tricks, and Tools Up: Introduction to Linux-like Environments Previous: make

Regular Expressions

Regular expressions represent patterns of text. Here are a few examples to get us started. I'm looking for a love song in my guitar archives:
$ grep -l love guitar/*
guitar/50-Ways.crd
guitar/American-Pie.pro
guitar/At-17.pro
guitar/Best-Of-My-Love.crd
guitar/Boxer.tab
$

Boxer? Love? Oops, that's glove. Not only that, I missed the case variants of that. Besides, love's too mooshy. I want all the songs with 'romance' and 'candles' in the lyrics. This is a job for perl:

$ perl -n0e 'print($ARGV,"\n") if (/\Wlove\W/i and /\Wwife\W/i and \
/\Wmoon/i)' guitar/*
guitar/space-oddity
$

Hmm. Not exactly the kind of song I was looking for.



Reece Kimball Hart
1998-03-18