unix in a nutshell 3rd ed 1999

615 329 0
unix in a nutshell 3rd ed 1999

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Unix in a Nutshell, Third Edition by Arnold Robbins Copyright © 1999, 1992, 1989 O’Reilly & Associates, Inc. All rights reserved. Published by O’Reilly & Associates, Inc., 101 Morris Street, Sebastopol, CA 95472. Editors: Mike Loukides and Gigi Estabrook Production Editor: Mary Anne Weeks Mayo Printing History: May 1989: First Edition. June 1992: Second Edition. August 1999: Third Edition. Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of O’Reilly & Associates, Inc. The association of the image of a tarsier and the topic of Unix in a Nutshell is a trademark of O’Reilly & Associates, Inc. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and O’Reilly & Associates, Inc. was aware of a trademark claim, the designations have been printed in caps or initial caps. UNIX is a trademark of X/Open Limited. OPEN LOOK is a trademark of Unix System Laboratories. SunOS, Solaris, and OpenWindow are trademarks of SunSoft. While every precaution has been taken in the preparation of this book, the publisher assumes no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein. ISBN: 1-56592-427-4 [6/01] [M] ,COPYRIGHT.5209 Page iv Thursday, October 18, 2001 4:31 PM About the Author Arnold Robbins, an Atlanta native, is a professional programmer and technical author. He is also a happy husband, the father of four very cute children, and an amateur Talmudist (Babylonian and Jerusalem). Since late 1997, he and his family have been living happily in Israel. Arnold has been working with Unix systems since 1980, when he was introduced to a PDP-11 running a version of Sixth Edition Unix. He has been a heavy awk user since 1987, when he became involved with gawk, the GNU project’s version of awk. As a member of the POSIX 1003.2 balloting group, he helped shape the POSIX stan- dard for awk. He is currently the maintainer of gawk and its documentation. The documentation is available from the Free Software Foundation (http://www.gnu.org) and has also been published by SSC (http://www.ssc.com)asEffective AWK Programming. O’Reilly has been keeping him busy: he is coauthor of the second edition of sed & awk, and coauthor of the sixth edition of Learning the vi Editor. Colophon Our look is the result of reader comments, our own experimentation, and feedback from distribution channels. Distinctive covers complement our distinctive approach to technical topics, breathing personality and life into potentially dry subjects. The animal featured on the cover of Unix in a Nutshell is a tarsier, a nocturnal mam- mal related to the lemur. Its generic name, Tarsius, is derived from the animal’s very long ankle bone, the tarsus. The tarsier is a native of the East Indies jungles from Sumatra to the Philippines and Sulawesi, where it lives in the trees, leaping from branch to branch with extreme agility and speed. A small animal, the tarsier’s body is only six inches long, followed by a ten-inch tufted tail. It is covered in soft brown or grey silky fur, has a round face, and huge eyes. Its arms and legs are long and slender, as are its digits, which are tipped with rounded, fleshy pads to improve the tarsier’s grip on trees. Tarsiers are active only at night, hiding during the day in tangles of vines or in the tops of tall trees. They subsist mainly on insects, and though very curious animals, tend to be loners. Mary Anne Weeks Mayo was the production editor and copyeditor for Unix in a Nut- shell, Third Edition; Ellie Maden, Ellie Cutler, and Jane Ellin provided quality control. Maureen Dempsey, Colleen Gorman, and Kimo Carter provided production assis- tance. Lenny Muellner provided SGML support. Seth Maislin wrote the index. Edie Freedman designed the cover of this book, using a 19th-century engraving from the Dover Pictorial Archive. The cover layout was produced by Kathleen Wilson with Quark XPress 3.32 using the ITC Garamond font. Whenever possible, our books use RepKover™, a durable and flexible lay-flat binding. If the page count exceeds Rep- Kover’s limit, perfect binding is used. The inside layout was designed by Alicia Cech, based on a series design by Nancy Priest, and implemented in gtroff by Lenny Muellner. The text and heading fonts are ITC Garamond Light and Garamond Book. This colophon was written by Michael Kalantarian. ,AUTHOR.COLO.5055 Page 3 Thursday, October 18, 2001 4:31 PM ,AUTHOR.COLO.5055 Page 4 Thursday, October 18, 2001 4:31 PM To my wife, Miriam. May our dreams continue to come true. To my childr en, Chana, Rivka, Nachum, and Malka. 18 October 2001 15:53 18 October 2001 15:53 Ta ble of Contents Pr eface xiii Part I: Commands and Shells Chapter 1 —Intr oduction 3 Merging the Traditions 3 Bundling 4 What’s in the Quick Reference 5 Beginner’s Guide 6 Guide for Users of BSD-Derived Systems 9 Solaris: Standard Compliant Programs 10 Chapter 2 —Unix Commands 11 Alphabetical Summary of Commands 12 Chapter 3 —The Unix Shell: An Overview 201 Intr oduction to the Shell 201 Purpose of the Shell 202 Shell Flavors 202 Common Features 204 Dif fering Featur es 205 vii 18 October 2001 15:53 Chapter 4 —The Bourne Shell and Korn Shell 207 Overview of Features 207 Syntax 208 Variables 214 Arithmetic Expressions 220 Command History 222 Job Control 223 Invoking the Shell 224 Restricted Shells 225 Built-in Commands (Bourne and Korn Shells) 225 Chapter 5 —The C Shell 260 Overview of Features 260 Syntax 261 Variables 265 Expr essions 270 Command History 273 Job Control 275 Invoking the Shell 276 Built-in C Shell Commands 277 Part II: Text Editing and Processing Chapter 6 —Patter n Matching 295 Filenames Versus Patterns 295 Metacharacters, Listed by Unix Program 296 Metacharacters 297 Examples of Searching 299 Chapter 7 —The Emacs Editor 302 Intr oduction 302 Summary of Commands by Group 304 Summary of Commands by Key 311 Summary of Commands by Name 315 Chapter 8 —The vi Editor 321 Review of vi Operations 321 Movement Commands 324 Edit Commands 326 viii 18 October 2001 15:53 Saving and Exiting 327 Accessing Multiple Files 328 Interacting with Unix 328 Macr os 329 Miscellaneous Commands 329 Alphabetical List of Keys 329 Setting Up vi 332 Chapter 9 —The ex Editor 337 Syntax of ex Commands 337 Alphabetical Summary of ex Commands 339 Chapter 10 —The sed Editor 349 Conceptual Overview 349 Command-Line Syntax 350 Syntax of sed Commands 350 Gr oup Summary of sed Commands 352 Alphabetical Summary of sed Commands 353 Chapter 11 —The awk Programming Language 361 Conceptual Overview 361 Command-Line Syntax 363 Patter ns and Procedur es 363 Built-in Variables 366 Operators 366 Variables and Array Assignments 367 User-Defined Functions 368 Gr oup Listing of awk Functions and Commands 369 Implementation Limits 369 Alphabetical Summary of Functions and Commands 370 Part III : Te xt For matting Chapter 12 —nroff and trof f 381 Intr oduction 381 Command-Line Invocation 382 Conceptual Overview 383 Default Operation of Requests 387 Gr oup Summary of Requests 390 Alphabetical Summary of Requests 392 ix 18 October 2001 15:53 Escape Sequences 405 Pr edefined Registers 407 Special Characters 408 Chapter 13 —mm Macr os 413 Alphabetical Summary of mm Macros 413 Pr edefined String Names 429 Number Registers Used in mm 429 Other Reserved Macro and String Names 432 Sample Document 432 Chapter 14 —ms Macr os 434 Alphabetical Summary of ms Macros 434 Number Registers for Page Layout 440 Reserved Macro and String Names 440 Reserved Number Register Names 441 Sample Document 441 Chapter 15 —me Macr os 443 Alphabetical Summary of me Macros 443 Pr edefined Strings 454 Pr edefined Number Registers 455 Sample Document 456 Chapter 16 —man Macros 458 Alphabetical Summary of man Macros 458 Pr edefined Strings 462 Inter nal Names 463 Sample Document 463 Chapter 17 —troff Prepr ocessors 465 tbl 466 eqn 469 pic 473 refer 481 x 18 October 2001 15:53 [...]... command-line arguments of the form var=value See Chapter 11, The awk Programming Language, for more information (including examples) on awk awk Unix Commands Options -f file Use program instructions contained in file, instead of specifying pr ogram on the command line -Fc Treat input file as fields separated by character c By default, input fields are separated by runs of spaces and/or tabs banner banner characters... characters Print characters as a poster on the standard output Each word supplied must contain ten characters or less basename pathname [suffix] basename Given a pathname, strip the path prefix and leave just the filename, which is printed on standard output If speci ed, a filename suffix (e.g., c) is removed also basename is typically invoked via command substitution (‘ ‘) to generate a filename See also dirname... /usr/ccs/bin/ar [-V] key [args] [posname] archive [files] Maintain a group of files that are combined into a file archive Used most commonly to create and update library files as used by the loader (ld) Only one key letter may be used, but each can be combined with additional args (with no separations between) posname is the name of a file in archive When moving or replacing files, you can specify that they... a GNU version called gawk) pr ogram instructions have the general form: pattern { procedure } 16 18 October 2001 14:52 Chapter 2 – Unix Commands patter n and pr ocedure are optional When speci ed on the command line, pr ogram must be enclosed in single quotes to prevent the shell from interpreting its special symbols Any variables speci ed in pr ogram can be assigned an initial value by using command-line... Unix Commands would change their values through assignment Letters A F are treated as digits whose values are 10–15 bc ibase = n Numbers that are input (e.g., typed) are read as base n (default is 10) Unix Commands obase = n Numbers displayed are in base n (default is 10) Note: once ibase has been changed from 10, use digit A to restore ibase or obase to decimal scale = n Display computations using... math library bc is a language (and compiler) whose syntax resembles that of C bc consists of identifiers, keywords, and symbols, which are briefly described here Examples follow at the end Identifiers An identifier is a single character, consisting of the lowercase letters a z Identifiers are used as names for variables, arrays, and functions Within the same program you may name a variable, an array, and... Get information on a command Reduce a job’s priority Preserve a running job after logging out Set your login password Produce a transcript of your login session Report misspelled words Become a superuser banner bc cal calendar clear man nice nohup passwd script spell su Printing cancel lp lpstat pr Cancel a printer request Send to the printer Get printer status Format and paginate for printing Programming... that the current entry continues on the next page The continuation is marked by aA final word about syntax In many cases, the space between an option and its argument can be omitted In other cases, the spacing (or lack of spacing) must be followed strictly For example, -wn (no intervening space) might be interpreted differently from -w n It’s important to notice the spacing used in option syntax... Particularly on Solaris, useful commands are spread across a number of different “bin” directories, such as /usr/ccs/bin, /usr/dt/bin, /usr/java/bin, and /usr/ openwin/bin, and not just /usr/bin and /usr/ucb In such cases, this book provides the full pathname, e.g., /usr/ccs/bin/make In some instances, a symbolic link for a command exists in /usr/bin to the actual command elsewhere Each entry is labeled... Reference Manual and Pr ogrammer’s Refer ence Manual for Unix System V Release 4 (SVR4) This chapter describes additional commands from the compatibility packages; these commands are prefixed with /usr/ucb, the name of the directory in which they reside Also included here are commands specific to Solaris 7, such as those for using Java and the occasional absolutely essential program available from the Internet . those designations appear in this book, and O’Reilly & Associates, Inc. was aware of a trademark claim, the designations have been printed in caps or initial caps. UNIX is a trademark of X/Open. PM About the Author Arnold Robbins, an Atlanta native, is a professional programmer and technical author. He is also a happy husband, the father of four very cute children, and an amateur Talmudist. distinctive approach to technical topics, breathing personality and life into potentially dry subjects. The animal featured on the cover of Unix in a Nutshell is a tarsier, a nocturnal mam- mal

Ngày đăng: 24/04/2014, 09:20

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan