What’s GNU in Old Utilities, Part Seven
Here’s the last in a series about new features of perennial utilities. This time: date, wc, du, and more.
Thursday, April 20th, 2006
A lot of utilities have changed since the early days of Unix. This month, let’s take one last look at new features added to a few of the most common Linux utilities, including diff, wc, du, date, touch, and sed.
What’s Different About diff
GNU diff version 2.8.1 has more than forty options. (The Seventh Edition diff had four.) Covering all forty is impractical, so let’s focus on the customizable output formats of GNU diff.
The Seventh Edition diff had its default output format and the –e and –f formats. Later, the context (–c) format was added, then came the unified (–u) format. Now diff has the –D NAME option to merge two C language files into a single file with the preprocessor directives #ifdef NAME and #ifndef NAME. Modern diff also has a series of options such as ––line-format= fff, where fff is a printf()- like string, to control how diff formats difference listings. The latter series of options lets you produce almost any type of output.
Listing One shows two short files with the normal output format, the unified format, and a custom format using the line-format options.