35.3 Alternatives to fmtfmt ( 35.2 ) is hard to do without once you've learned about it. Unfortunately, it's not available in some versions of UNIX. You can get the GNU version from the CD-ROM. But it's also relatively easy to emulate with sed ( 34.24 ) and nroff ( 43.13 ) . Using those two utilities also lets you take advantage of the more-sophisticated formatting and flexibility that sed and nroff macros ( 43.15 ) can give you. (If you're doing anything really fancy, like tables with tbl ( 43.15 ) , [1] you might need col or colcrt ( 43.18 ) to clean up nroff 's output.)
Here's the script:
#!/bin/sh sed '1i\ .ll 72\ .na\ .hy 0\ .pl 1' $* | nroff
The reason this is so complicated is that,
by default,
nroff
makes some assumptions you need to change.
For example, it assumes an 11-inch page (66 lines), and will add
blank lines to a short file (or the end of a long file).
The quick-and-dirty workaround to this is to manually put the
nroff
request
.pl 1
(page length 1 line) at the top of the text you want to
reformat.
nroff
also tends to justify lines; you want to turn
this off with the A fancier script would take a -nn line-length option and turn it into a .ll request for nroff , etc. - |
|