Monday, November 26, 2007

Free Windows disk image tool

LifeHacker has an interesting article about a free Windows disk image tool called DriveImage XML. It's reasonably quick and offers the capability to restore a disk to an earlier state.

Monday, November 19, 2007

I/O redirection into an editor

Sometimes it's handy to redirect the output of a Linux/Unix command into an editor. One reason to do this might be to try to weed out unwanted search pattern matches when running grep. Fortunately the Linux (and before that Unix) developers have anticipated this need. Editors like vi, vim, gvim, and gedit (and possibly others I'm not aware of) can all accept the output of a command as the "file" being edited.

For example, you can direct the output of a grep command to gvim with the following command:

grep searchPattern | gvim -

If you really want to get fancy, you can pass a command to gvim to cause it to search for the same pattern you used grep to find by using the -c argument.

grep searchPattern | gvim -c/searchPattern -

Since searchPattern appears twice on the command line and engineers never want to type any extra characters, I'd define a command alias to perform this action. Since there are so many shells out there, I'll leave that as an exercise for the reader.

Sunday, November 18, 2007

Readability rating

I think the rating should be more like "Evil Genius". It must be all my posts about obscure Unix commands, eh?

Friday, November 16, 2007

Adding color to grep output

Most of the longtime Unix users like me love grep. Regular expressions make the silly wildcards available in Windows seem completely underwhelming.

One thing which I find makes grep even more useful is to configure it to highlight matching terms. Like most things I decide would be useful, a little poking about in the man pages shows that the Unix developers have anticipated my needs yet again. They've added a couple environment variables which can tell grep to highlight matching terms in the color of your choosing. Since I prefer my xterm windows with a dark background and light foreground colors, I find the following colors work well. Note - I use tcsh at home so you may need to alter these commands a bit to get them to work with your preferred shell.

# highlight search terms with a red background and white foreground
setenv GREP_COLOR '01;37;41'
setenv GREP_OPTIONS '--color=auto'

A word of warning is in order. I've found that using these terms can cause strange failures in seemingly unrelated activities. For example, I build Linux kernel modules at work and I've discovered that fails if I've got the grep color environment variables set (in the modpost step). So I've defined command aliases to set and unset the environment variables. That way I can easily enable grep colors before performing a grep and disable them again before doing something which may fail if grep colors are enabled.

Saturday, November 03, 2007

Rudy Rucker

One of my favorite SciFi authors, Rudy Rucker, has kindly released his latest novel called Postsingular under a Creative Commons license. This is a great way for people unfamiliar with Rudy's work to try it out. If you like it (and I'm sure most people will) please buy his earlier books. I like to keep my favorite authors gainfully employed because that means more good books for me to read.

Sunday, October 21, 2007

Feeling old

I was in the hospital visiting my grandmother this weekend. Last week she had fallen while trying to put on her shoes and broke her leg near the hip. Thank goodness it wasn't her hip as that's supposed to be much harder to recover from. So thanks to a metal pin and 3 screws installed Thursday, she's starting the long hard road to recovery.

I was amazed that the physical therapist was able to get her to try a few steps while I was there. She was in a lot of pain and was reluctant to do anything which made it worse, such as moving the injured leg. The thing which was toughest for me to take was the sounds she made when the pain hit her. I was also struck by how small and frail she looks now. I know it's been a long gradual process but it really struck me while watching her struggle with the pain.

It's strange how the roles feel reversed now. When I was small, she used to take care of me while my mother was at work. She was always able to help with anything I needed. Now we've got to do the same for her. It seems kind of strange for all of us and is taking a little getting used to.

Wednesday, October 17, 2007

Hazmat Modine

A couple months ago, my wife was reading the latest edition of the schedule of entertainment from our neighborhood community center. It's well worth doing because they always have some sort of program which we find entertaining. It turns out they had managed to attract one of my favorite new bands, Hazmat Modine, to perform near our house.

You might have heard them on NPR about a year ago. I didn't catch that program but a friend did and was so amazed by their music that he felt obliged to tell me about it. After listening to his CD, I had to buy a copy for myself.

As much as I like their CD, they were much better in person. I highly recommend seeing them if you get the chance. I can hardly wait for their next CD to be released. Yes, they're really that good.

You can search on YouTube for samples of their performances. Here's one to get you started.