Thursday, May 29, 2008

Nerdy Limerick #3

Sed has been pissing me off the last couple days. FYI, if you're unfortunate enough to be using sed to do something, here's a couple things I have learned (re-learned?) recently:

1. If you want to use the + to indicate one-or-more, it must be escaped. Check out this lovely example:

lark [1045] head -n 1 1028/1028-10.txt | sed "s/[ ]+/\n/g" | wc -l
1
lark [1046] head -n 1 1028/1028-10.txt | sed "s/[ ]\+/\n/g" | wc -l
976

Ahhhh what a difference one little backslash can make.

2. \s does NOT mean white space. Doh.

All that ranting about sed reminded me that I had written another nerdy limerick and not posted it, so here it is:

Limerick #3

if you work in Euclidean spaces
and you want an orthogonal basis
you can see what you get
from using Gram-Schmitt
but it might not be nice in all cases

0 comments: