$book = '..'?>include "$book/mh.php"; includeHeader('e-execit.html', 'e-forwed.html'); ?>
Section List Folders in Columns with fols gives an overview of this script. Here is the fols script (you might want to open it in a separate browser window). To install it, see the Section Programs in This Book's Archive.
The archive has a new version of fols, the program that's shown in the Section Writing Shell Scripts for MH. fols prints the folders -fast output in columns. The case statement checks the command line. It catches errors in the number of arguments or the contents of $1. The $#$1 pattern, the number of command-line arguments and the contents of $1 (if any), is matched against the corresponding patterns. If there are no arguments, or if there's exactly one argument and it starts with -r, the test succeeds. That may look tricky, but it's really simple. A two-line sed command reads the output of folders. There are two sed expressions (with -e before each). The first expression puts a plus sign (+) after the current folder name; it uses folder -fast, inside backquotes, to find the current folder (foldername). The second expression only matches lines that are longer than 18 characters (which is how wide the pr -4 -l78 command makes its columns). It takes the first eight characters and the last nine characters of a folder name, ignores the middle -- then outputs the two pieces with an equal sign (=) between them. This makes an 18-character-long folder name with an = replacing what's been cut out. Not all UNIX systems have programs especially designed to write output in columns, but all systems should have pr. Here, it's used to make columns by giving a page length of 1 (-l1) with no headers (-t), a line 78 characters wide (-w78), and four columns (-4). The page length of 1 with four columns means that pr will read four lines of input, spread them left-to-right across the line, and then output it. includeFooter('$Date: 2006-05-31 15:13:43 -0700 (Wed, 31 May 2006) $', 'OReilly: 1991, 1992, 1995; Jerry: 1996, 1997, 1998, 1999, 2000, 2002, 2004'); ?>