Archive for February, 2009

how do i grep on a term with a $ in it such as $foo? i tried enclosing it in quotes but that doesn’t help

Monday, February 16th, 2009

Enclose the $ in square brackets [ .. ], that is, specify the special character as a character class. For example,

grep ‘[$]foo’ file.txt

Negation in regular expressions

Saturday, February 14th, 2009

How to search for lines that don’t contain a particular pattern is fairly easy in some programs, obscure in others, and almost impossible yet in others. That is, assuming your program of choice supports regular expressions. I review how to achieve this functionality in Perl, Vim, grep, and vi.