Thursday, October 30, 2003

Cool unix piping
Geek alert!

I'm code reviewing this morning. To do this, I grep for the files containing "jjw needed" (these are the files I have to review), more the diff file, look at the diffs to decide if I need to make comments in the file, and then edit the file. This was taking some manual effort (find the file, type in the name, etc.), which gets to be a pain when you have 100s of files to look at. Played around a bit and figured out that I could use the following commands:

more `grep -l "jjw needed" * | head -4 | tail -1`_diff
xemacs `grep -l "jjw needed" * | head -4 | tail -1`

The 'grep' searches for the files and lists just the file name, 'head' displays the first N results (in this case 4) and then tail displays the last N resluts, in this case 1. This basically perfoms a 'more' on the 4th file, appending "_diff" to the file name. Then the next command edits that file.

While I still long for VMS, and think it is a much better OS, there are some cool things you can do with Unix.

No comments: