sed and make

It’s funny how you can go years without using tools and then start using them all the time.  I haven’t done anything with sed other than the occasional sed ’s/foo/bar/’ in a pipeline since I got comfortable with awk (something like 1994 or 1995), but all of a sudden I find I’m using it daily, and not just the s command.

Part of this has to do with my new obsession with make.  I’m lazy and not much of a programmer, so while I usually use make to compile, if I have to write a Makefile, I usually use:touch Makefile
and just use the default rules.  However, I recently came up with the idea of writing a makefile that could be used to build a Solaris package from a software package that would normally be built using “tar xvzf X.tar.gz; cd X; ./configure configure options; make install”  Actually, my original idea was to build a Makefile just for building AMANDA packages, since as a lazy person I usually get my software from Sunfreeware.com but I quickly decided it would be more useful and interesting to generalize it.  Then yesterday, I sat down to setup the final patchlists for the 5 servers I’d scheduled for patching this morning and decided that make would be a good way to further automate my process (I’ve been using a script, but then I run into trouble when I only want to run part of the process for some reason – like creating my patch list for  prod and test today but only backing up configuration files that will be changed for test today.)

For some reason, I find that sed seems much cleaner than awk in a Makefile.  (This might be because, on Solaris at least, you seem to need to write your sed script as sed -e cmd1 -e cmd2 …)  I suspect that sed is much more efficient than awk or nawk, but I’ve never profiled them (hmmm, there’s a good activity for a dull day…)

However, make is not the only source of my renewed love affair with sed.  I think it actually started in my personal life.  I’m taking a Spanish class and each class we learn one or more tricks for recognizing (and converting) English words that are similar or identical to Spanish words.  I’ve started writing my notes about this in sed (I actually wrote a script to run against the system dictionary as well, but I quickly converted it to nawk so I could do nicer formatting without pulling in nroff.)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: