SHARE
Facebook X Pinterest WhatsApp

LinuxWorld: Using the m4 Macro Processor

Written By
thumbnail
Web Webster
Web Webster
Apr 26, 2000

[ Thanks to S.Ramaswamy for this link.
]

“Chief among the the unsung heroes of Linux and Unix is m4.
Unsung? Well, for instance, although m4 has been a standard part of
Unix since version 7, no mention is made of it in that great
O’Reilly & Associates book, Unix Power Tools. What is it
about m4 that makes it so useful, and yet so overlooked? m4 — a
macro processor — unfortunately has a dry name that disguises a
great utility. A macro processor is basically a program that scans
text and looks for defined symbols, which it replaces with other
text or other symbols.
Thus, m4 is a powerful general-purpose
utility that can be used to automate many tasks people often end up
doing in sed, awk, perl, and even their favorite text editor. Even
so, it still doesn’t seem like a macro processor is that big of a
deal. Unix developers already have a built-in macro processor, in
the form of the C preprocessor, in their compiler. Perhaps this is
what accounts for m4’s relative neglect. Whatever the case may be,
this article will show Linux users the power and usefulness of this
software tool.”

“The contemporary implementation of m4 on a Linux system is GNU
m4, which follows System V Release 3 m4, with extensions. I am
aware of no other version of m4 that has been ported to Linux. m4
implementations on BSD may differ slightly. However, m4 is m4, and
this article should be useful for other Unix users, too. The latest
version is 1.4, which was released in October 1994.”

“The most important of the built-in macros is define(), which
allows users to define their own macros. For example,
define(author, Paul Dunne) defines a macro “author” — any
occurrence of which will expand to the string “Paul Dunne”. m4
expands macro names into their defining text as soon as it possibly
can.”

Complete
Story

thumbnail
Web Webster

Web Webster

Web Webster has more than 20 years of writing and editorial experience in the tech sector. He’s written and edited news, demand generation, user-focused, and thought leadership content for business software solutions, consumer tech, and Linux Today, he edits and writes for a portfolio of tech industry news and analysis websites including webopedia.com, and DatabaseJournal.com.

Recommended for you...

Red Hat reveals major enhancements to Red Hat Enterprise Linux AI
sjvn
Oct 22, 2024
How to Find AWS EC2 Instance Type Over SSH (6 Methods)
Benny Lanco
Sep 23, 2024
Crond: Daemon to Execute Scheduled Commands
Rose Hosting Blog
Sep 20, 2024
A Detailed Introduction to Oracle VirtualBox
Senthil Kumar
Sep 19, 2024
Linux Today Logo

LinuxToday is a trusted, contributor-driven news resource supporting all types of Linux users. Our thriving international community engages with us through social media and frequent content contributions aimed at solving problems ranging from personal computing to enterprise-level IT operations. LinuxToday serves as a home for a community that struggles to find comparable information elsewhere on the web.

Property of TechnologyAdvice. © 2025 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.