before

Using find and grep to print lines before and after what you’re searching for

A cool thing about the Unix/Linux grep command is that you can show lines before and after a pattern match with the -B and -A options. As an example, I just used this combination of find and grep to search for all Scala files under the current directory that contain the string null. This command prints five lines before and after each null line in each file:

$ find . -type f -name "*.scala" -exec grep -B5 -A5 null {} \;

That’s good stuff, but it prints a really long list of lines, and I can’t tell the output of one file from another. To fix this, I put the following code in a file named helper.sh, and made it executable:

Zen Foundation “bookshelf” postcard designs (before and after)

This photo shows two attempts at creating images for my next Zen Foundation postcard. The first image represents my first “final” attempt. In this case I knew I wasn’t blown away by the image, but it was the best I could do that night. I posted it on Facebook, got some feedback from a friend, and eventually came up with the second image, which is what I decided to go with.

(Click the image to see a much larger version of it.)

Unix `sed` examples: how to insert text before and after existing lines

If you ever need to use the Unix/Linux sed command to insert text before or after a line of text in an existing file, here's how I just ran several sed commands to update my old Function Point Analysis tutorial to have a format that doesn't look like it was created in the 1990s.

This tutorial consists of over 40 files, and I had eight changes I wanted to make each file. So I had two choices: modify each file by hand over the next six hours, or run a series of sed commands and be done in 30 minutes. (I chose the sed commands.)

A typical day in the life of an iPhone owner

The iPhone really has a way of changing your day. Zealous over-statement you say? Let's explore it.

First, let's take a look at a typical day in the life of an iPhone owner: