An Introduction to m4

799
Though it has been a standard part of Unix since V7, m4 remains one of the “unsung heroes”. This article is the first of three aiming to show how useful m4 can be.” m4 is one of the unsung heroes of Linux and Unix. For instance, in that great book Unix Power Tools, not a single mention is made of it, though m4 has been a standard part of Unix since V7. So, what is it about m4 that makes it so useful, and yet so over-looked?

m4 is a “macro processor”: a dry name that disguises a great facility. A macro-processor is basically a program that scans text looking for defined symbols, which it replaces by other text — or other symbols. Thus, it is a powerful general-purpose utility that can be used to automate many tasks people often end up doing in sed, awk, perl, or even their favourite text editor. However, this power and it’s general-purpose nature is not at all obvious in the bare name, “macro processor”. Also, Unix developers already have a built-in macro processor, in the form of the C pre-processor, built into their compiler. Perhaps it is this that accounts for m4’s relative neglect. Whatever, this article hopes to show all Unix users the power and usefulness of this software tool.

Link: dhs.org

Category:

  • Linux