Unix at the Core — Still Viable

Yesterday, the nice person and the Unix Curmudgeon were prowling our favorite thrift store (the one we donate our unwanted stuff to), and we came across a shelf of old Unix books, mostly O’Reilly titles.  Some were a bit dated, like “High Performance Computing,” which, today, means huge Linux Clusters on multi-core AMD and Intel CPUs, but in 1993 meant RISC processors like Sun’s SuperSPARC and HP’s PA-RISC.  But, the book works on core principles, so many of the chapters are still valid advice and technique for tweaking programs on any computer, so it goes on the shelf as a reference and memory jogger.

The real prize in this blast from the past is a Hayden Books tome dated 1987, UNIX Text Processing, with Tim O’Reilly’s name on the by-line, as co-author with Dale Dougherty and acknowledgement to “the staff of O’Reilly & Associates.”  Much of this thick book is a crusty introduction to Unix and basic utilities, as the target audience are word smiths and other folks who may not have heard of Unix,  rather than programmers and administrators.  But, at the chewy core is a review of the Typesetting RunOFF system (troff), with all the popular macro packages, plus the pre-processors tbl, pic, and eqn.  As a bonus, the authors show us how to use those venerable command-line tools like awk to slice, dice, and embroider the raw markup.

“Big Deal,” you say.  OpenOffice Writer does all that stuff automatically.  Markup languages are out, WYSIWYG is in–in fact, so ubiquitous that nobody calls it that anymore.  Well, markup still exists, though many of us, myself included, often use OpenOffice and content management systems (like WordPress, with which this blog is written) to create and edit documents, though I find myself flipping over to the “source” view and tweaking the HTML manually in nearly every post.

But, wait–there was that word: manually.  What if we have a document format in which we want to generate documents automatically?  Oh, right–we can generate XML and write a parser for it, or write PHP code that converts database tables into HTML tables, and we can even use PDF libraries to write output directly to PDF.  Still, for a lot of documents, writing complex scripts is overkill, and needs a lot of debugging.

For a lot of ad hoc documents–prototypes or one-time reports, it may be much simpler to write a template for a troff macro, populate the template with our data using a simple filter script, and pipe it all to the Unix text formatting utilities.   With pic, you can even automatically generate graphs from your data, and embed them in the output.  The advantage of using the text formatting utilities is that you are in the realm of the core Unix philosophy–piping data from one utility that does one thing well to another, so you can easily add filters on the front end or backend to adapt to different data sources or different output formats, or quickly change the layout.

One thought on “Unix at the Core — Still Viable”

Comments are closed.