pcregrep

In: Uncategorized

3 Dec 2009

I recently learned about pcregrep, a enhanced grep that supports perl regex syntax. This is great for searches that span multiple line. For example, the other day I was looking thru old css files that had a border set to 0 to be removed due to the inclusion of a reset.css lib. So ….

pcregrep --color --exclude_dir=".svn" --exclude="reset.css" -rn -M "\bimg\b[^{]*?{[^}]*?(padding|margin|border)\s*:\s*0\s*;" .

Piping its output to a few commands, and I can search for bad code, find it’s line number, and who to blame:

$ pcregrep --exclude_dir=".svn" -rn "id=['\"]\w+ " . | awk -F:  '{str="svn blame " $1 " 2>/dev/null | head -" $2 " | tail -1"; printf "%s:%d", $1, $2; system(str)}'

In this case, it was me?! :p

About this blog

This portifolio represents a brief sampling of my work. More thorough demonstrations and walk-thrus of my latest and greatest work are available via remote virtual session on DimDim, a free flash based web conferencing tool.

Also note that I recently joined StackOverflow where you will find me asking and answering many web development questions.