UNIX Text Processing Tools—Programs for Sorting, Compar- Ing, and in Various Ways Examining the Contents of Text Files
Total Page:16
File Type:pdf, Size:1020Kb
UNIX® TEXT PROCESSING DALE DOUGHERTY AND TIM O’REILLY and the staffofO’Reilly & Associates, Inc. CONSULTING EDITORS: Stephen G. Kochan and PatrickH.Wood HAYDEN BOOKS ADivision of HowardW.Sams & Company 4300 West 62nd Street Indianapolis, Indiana 46268 USA Copyright © 1987 Dale Dougherty and Tim O’Reilly FIRST EDITION SECOND PRINTING — 1988 INTERNET "UTP Revival" RELEASE — 2004 The UTP RevivalRelease is distributed according to the terms of the Creative Commons Attribution License. A copyofthe license is available at http://creativecommons.org/licenses/by/1.0 International Standard Book Number: 0-672-46291-5 Library of Congress Catalog Card Number: 87-60537 Trademark Acknowledgements All terms mentioned in this book that are known to be trademarks or service marks are listed below. Nei- ther the authors nor the UTP Revivalmembers can attest to the accuracyofthis information. Use of a term in this book should not be regarded as affecting the validity of anytrademark or service mark. Apple is a registered trademark and Apple LaserWriter is a trademark of Apple Computer,Inc. devps is a trademark of Pipeline Associates, Inc. Merge/286 and Merge/386 are trademarks of Locus Computing Corp. DDL is a trademark of Imagen Corp. Helvetica and Times Roman are registered trademarks of Allied Corp. IBM is a registered trademark of International Business Machines Corp. Interpress is a trademark of Xerox Corp. LaserJet is a trademark of Hewlett-Packard Corp. Linotronic is a trademark of Allied Corp. Macintosh is a trademark licensed to Apple Computer,Inc. Microsoft is a registered trademark of Microsoft Corp. MKS Toolkit is a trademark of Mortice Kern Systems, Inc. Multimate is a trademark of Multimate International Corp. Nutshell Handbook is a trademark of O’Reilly & Associates, Inc. PC-Interface is a trademark of Locus Computing Corp. PostScript is a trademark of Adobe Systems, Incorporated. PageMaker is a registered trademark of Aldus Corporation. SoftQuad Publishing Software and SQtroffare trademarks of SoftQuad Inc. WordStar is a registered trademark of MicroPro International Corp. UNIX is a registered trademark of The Open Group. VP/ix is a trademark of Interactive Systems Corp. and Phoenix Technologies, Ltd. CONTENTS Preface xi 1 From Typewriters to Word Processors 1 AWorkspace ..............................................................................................................................................2 Tools for Editing........................................................................................................................................3 Document Formatting ................................................................................................................................4 Printing ......................................................................................................................................................6 Other UNIX Text-Processing Tools ...........................................................................................................7 2 UNIX Fundamentals 9 The UNIX Shell.........................................................................................................................................9 Output Redirection ..................................................................................................................................10 Special Characters ...................................................................................................................................14 Environment Variables ............................................................................................................................15 Pipes and Filters ......................................................................................................................................16 Shell Scripts.............................................................................................................................................17 3 Learning vi 19 Session 1: Basic Commands....................................................................................................................19 Opening a File .........................................................................................................................................20 Moving the Cursor...................................................................................................................................22 Simple Edits.............................................................................................................................................25 Session 2: Moving Around in a Hurry ....................................................................................................32 Movement by Screens .............................................................................................................................32 Movement by TextBlocks .......................................................................................................................34 Movement by Searches............................................................................................................................35 Movement by Line Numbers...................................................................................................................37 Session 3: Beyond the Basics .................................................................................................................38 Command-Line Options ..........................................................................................................................38 Customizing vi.......................................................................................................................................40 Edits and Movement ................................................................................................................................42 More Ways to Insert Text........................................................................................................................43 Using Buffers ...........................................................................................................................................43 Marking Your Place.................................................................................................................................45 Other Advanced Edits..............................................................................................................................46 4 nroff and troff 47 What the Formatter Does.........................................................................................................................48 Using nroff...........................................................................................................................................51 Using troff...........................................................................................................................................51 The Markup Language ............................................................................................................................54 Turning Filling On and Off......................................................................................................................55 Controlling Justification ..........................................................................................................................57 v vi Unix TextProcessing Hyphenation ............................................................................................................................................59 Page Layout .............................................................................................................................................60 Page Transitions .......................................................................................................................................70 Changing Fonts ........................................................................................................................................74 AFirst Look at Macros............................................................................................................................81 5 The ms Macros 85 Formatting a TextFile with ms ...............................................................................................................86 Page Layout .............................................................................................................................................86 Paragraphs ...............................................................................................................................................87 Changing Font and Point Size .................................................................................................................93 Displays ...................................................................................................................................................97 Headings ..................................................................................................................................................99 CoverSheet Macros...............................................................................................................................100 Miscellaneous Features .........................................................................................................................102 Page Headers and Footers ......................................................................................................................104