1. Trang chủ
  2. » Công Nghệ Thông Tin

Unix Shell Programming Third Edition phần 1 doc

69 223 0

Đ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

Thông tin cơ bản

Định dạng
Số trang 69
Dung lượng 1,37 MB

Nội dung

• Table of Contents • Index Unix® Shell Programming, Third Edition By Stephen G. Kochan, Patrick Wood Publisher : Sams Publishing Pub Date : February 27, 2003 ISBN : 0-672-32490-3 Pages : 456 Slots : 1 Unix Shell Programming is a tutorial aimed at helping Unix and Linux users get optimal performance out of their operating out of their operating system. It shows them how to take control of their systems and work efficiently by harnessing the power of the shell to solve common problems. The reader learns everything he or she needs to know to customize the way a Unix system responds. The vast majority of Unix users utilize the Korn shell or some variant of the Bourne shell, such as bash. Three are covered in the third edition of Unix Shell Programming. It begins with a generalized tutorial of Unix and tools and then moves into detailed coverage of shell programming. Topics covered include: regular expressions, the kernel and the utilities, command files, parameters, manipulating text filters, understanding and debugging shell scripts, creating and utilizing variables, tools, processes, and customizing the shell. • Table of Contents • Index Unix® Shell Programming, Third Edition By Stephen G. Kochan, Patrick Wood Publisher : Sams Publishing Pub Date : February 27, 2003 ISBN : 0-672-32490-3 Pages : 456 Slots : 1 Unix Shell Programming is a tutorial aimed at helping Unix and Linux users get optimal performance out of their operating out of their operating system. It shows them how to take control of their systems and work efficiently by harnessing the power of the shell to solve common problems. The reader learns everything he or she needs to know to customize the way a Unix system responds. The vast majority of Unix users utilize the Korn shell or some variant of the Bourne shell, such as bash. Three are covered in the third edition of Unix Shell Programming. It begins with a generalized tutorial of Unix and tools and then moves into detailed coverage of shell programming. Topics covered include: regular expressions, the kernel and the utilities, command files, parameters, manipulating text filters, understanding and debugging shell scripts, creating and utilizing variables, tools, processes, and customizing the shell. • Table of Contents • Index Unix® Shell Programming, Third Edition By Stephen G. Kochan, Patrick Wood Publisher : Sams Publishing Pub Date : February 27, 2003 ISBN : 0-672-32490-3 Pages : 456 Slots : 1 Copyright About the Authors We Want to Hear from You! Reader Services Chapter 1. Introduction Chapter 2. A Quick Review of the Basics Some Basic Commands Working with Files Working with Directories Filename Substitution Standard Input/Output and I/O Redirection Pipes Standard Error More on Commands Command Summary Exercises Chapter 3. What Is the Shell? The Kernel and the Utilities The Login Shell Typing Commands to the Shell The Shell's Responsibilities Chapter 4. Tools of the Trade Regular Expressions cut paste sed tr grep sort uniq Exercises Chapter 5. And Away We Go Command Files Variables Built-in Integer Arithmetic Exercises Chapter 6. Can I Quote You on That? The Single Quote The Double Quote The Backslash Command Substitution Exercises Chapter 7. Passing Arguments The $# Variable The $* Variable A Program to Look Up Someone in the Phone Book A Program to Add Someone to the Phone Book A Program to Remove Someone from the Phone Book ${n} The shift Command Exercises Chapter 8. Decisions, Decisions Exit Status The test Command The else Construct The exit Command The elif Construct The case Command The Null Command : The && and || Constructs Exercises Chapter 9. 'Round and 'Round She Goes The for Command The until Command More on Loops The getopts Command Exercises Chapter 10. Reading and Printing Data The read Command The printf Command Exercises Chapter 11. Your Environment Local Variables Exported Variables PS1 and PS2 HOME, James Your PATH Your Current Directory More on Subshells Your .profile File The TERM Variable The TZ Variable Exercises Chapter 12. More on Parameters Parameter Substitution The $0 Variable The set Command The IFS Variable The readonly Command The unset Command Exercises Chapter 13. Loose Ends The eval Command The wait Command The trap Command More on I/O Functions The type Command Exercises Chapter 14. Rolo Revisited Design Considerations rolo add lu display rem change listall Sample Output Exercises Chapter 15. Interactive and Nonstandard Shell Features Getting the Right Shell The ENV File Command-Line Editing Command History The vi Line Edit Mode The Line Edit Mode Other Ways to Access Your History Functions Integer Arithmetic The alias Command Arrays Job Control The Restricted Shell rsh Miscellaneous Features Compatibility Summary Exercises Appendix A. Shell Summary Startup Commands Comments Parameters and Variables Command Re-entry Quoting Filename Substitution I/O Redirection Exported Variables and Subshell Execution Functions Job Control Command Summary Appendix B. For More Information Online Documentation Documentation on the Web Books Index Copyright Copyright © 2003 by Sams Publishing All rights reserved. No part of this book shall be reproduced, stored in a retrieval system, or transmitted by any means, electronic, mechanical, photocopying, recording, or otherwise, without written permission from the publisher. No patent liability is assumed with respect to the use of the information contained herein. Although every precaution has been taken in the preparation of this book, the publisher and author assume no responsibility for errors or omissions. Nor is any liability assumed for damages resulting from the use of the information contained herein. Library of Congress Catalog Card Number: 2002115932 Printed in the United States of America First Printing: March 2003 06 05 04 03 4 3 2 1 Trademarks All terms mentioned in this book that are known to be trademarks or service marks have been appropriately capitalized. Sams Publishing cannot attest to the accuracy of this information. Use of a term in this book should not be regarded as affecting the validity of any trademark or service mark. Warning and Disclaimer Every effort has been made to make this book as complete and as accurate as possible, but no warranty or fitness is implied. The information provided is on an "as is" basis. The authors and the publisher shall have neither liability nor responsibility to any person or entity with respect to any loss or damages arising from the information contained in this book. Credits Acquisitions Editor Katie Purdum Development Editor Scott Meyers Managing Editor Charlotte Clapp Copy Editor Geneil Breeze Indexer Erika Millen Proofreader Jessica McCarty Technical Editor Michael Watson Interior Designer Gary Adair Cover Designer Gary Adair Page Layout Susan Geiselman Dedication To my father, Harry Wood —Patrick Wood To Gregory, Linda, and Julia for giving meaning to my life —Stephen G. Kochan About the Authors Stephen G. Kochan is the owner of TechFitness, a technology-based fitness company. Prior to that, he was president and CEO of Pipeline Associates, a company specializing in color printing software. Mr. Kochan is the author of several best-selling books on Unix and C programming, including the best-selling Programming in C. He also acted as Series Editor for the Hayden Unix System Library. Patrick Wood is the CTO of the New Jersey location of Electronics for Imaging. He was a member of the technical staff at Bell Laboratories when he met Mr. Kochan in 1985. Together they founded Pipeline Associates, Inc., a Unix consulting firm, where he was the Vice President. They coauthored Exploring the Unix System, Unix System Security, Topics in C Programming, and Unix Shell Programming. We Want to Hear from You! As the reader of this book, you are our most important critic and commentator. We value your opinion and want to know what we're doing right, what we could do better, what areas you'd like to see us publish in, and any other words of wisdom you're willing to pass our way. You can email or write me directly to let me know what you did or didn't like about this book—as well as what we can do to make our books stronger. Please note that I cannot help you with technical problems related to the topic of this book, and that due to the high volume of mail I receive, I might not be able to reply to every message. When you write, please be sure to include this book's title and author as well as your name and phone or email address. I will carefully review your comments and share them with the author and editors who worked on the book. Email: feedback@samspublishing.com Mail: Mark Taber Associate Publisher Sams Publishing 201 West 103rd Street Indianapolis, IN 46290 USA Reader Services For more information about this book or others from Sams Publishing, visit our Web site at www.samspublishing.com. Type the ISBN (excluding hyphens) or the title of the book in the Search box to find the book you're looking for. [...]... and when the file was last modified The information displayed last on the line is the filename itself $ ls -l programs total 4 -rwxr-xr-x 1 steve DP3725 -rwxr-xr-x 1 steve DP3725 -rwxr-xr-x 1 steve DP3725 358 Jun 25 13 : 31 collect 12 19 Jun 25 13 : 31 mon 89 Jun 25 13 :30 wb $ The dash in the first column of each line indicates that the three files collect, mon, and wb are ordinary files and not directories... originally written by Stephen Bourne at Bell Labs Since then, the IEEE created standards based on the Bourne shell and the other more recent shells The current version of this standard as of this revision is the Shell and Utilities volume of IEEE Std 10 03 .1- 20 01, also known as the POSIX standard This shell is what we propose to teach you about in this book The examples in this book were tested on both SunOS... do have an older Unix system that doesn't supply a POSIX-compliant shell, there's still hope We'll list resources at the end of this book where you can obtain free copies of three different POSIX-compliant shells Because the shell offers an interpreted programming language, programs can be written, modified, and debugged quickly and easily We turn to the shell as our first choice of programming language... intriguing (and often confusing) aspects of the shell: the way it interprets quotes By this point in the book, all the basic programming constructs in the shell will have been covered, and you will be able to write shell programs to solve your particular problems Chapter 11 , "Your Environment," covers a topic of great importance for a real understanding of the way the shell operates: the environment You'll... exported variables; subshells; special shell variables such as HOME, PATH, and CDPATH; and how to set up your profile file Chapter 12 , "More on Parameters," and Chapter 13 , "Loose Ends," tie up some loose ends, and Chapter 14 , "Rolo Revisited," presents a final version of a phone directory program called rolo that is developed throughout the book Chapter 15 , "Interactive and Nonstandard Shell Features,"... features of the shell that either are not formally part of the IEEE POSIX standard shell (but are available in most Unix and Linux shells) or are mainly used interactively instead of in programs Appendix A, "Shell Summary," summarizes the features of the IEEE POSIX standard shell Appendix B, "For More Information," lists references and resources, including the Web sites where different shells can be... all users currently logged in to the system: $ who pat tty29 Jul 19 14 :40 ruth tty37 Jul 19 10 :54 steve tty25 Jul 19 15 :52 $ Here, three users are logged in: pat , ruth , and steve Along with each user id, the tty number of that user and the day and time that user logged in is listed The tty number is a unique identification number the Unix system gives to each terminal or network device that a user... the user and the guts of the Unix system (the kernel), the shell was developed The shell is simply a program that reads in the commands you type and converts them into a form more readily understood by the Unix system It also includes some fundamental programming constructs that let you make decisions, loop, and store values in variables The standard shell distributed with Unix and Linux systems derives... the Unix system As far as you're concerned, it appears as though you have two different files Executing an ls command shows the two files separately: $ ls collect mon wb writeback $ Look what happens when you execute an ls -l: $ ls -l total 5 -rwxr-xr-x 1 steve DP3725 358 Jun 25 13 : 31 collect -rwxr-xr-x 1 steve DP3725 -rwxr-xr-x 2 steve DP3725 89 Jun 25 13 :30 wb -rwxr-xr-x 2 steve DP3725 89 Jun 25 13 :30... Red Hat Linux 7 .1 and Cygwin All examples, except some Bash examples in Chapter 15 , were run using the Korn shell, although many were also run with Bash Many Unix systems are still around that have Bourne shell derivatives and utilities not compliant with the POSIX standard We'll try to note this throughout the text wherever possible; however, there are so many different versions of Unix from so many . Index Unix Shell Programming, Third Edition By Stephen G. Kochan, Patrick Wood Publisher : Sams Publishing Pub Date : February 27, 2003 ISBN : 0-672-32490-3 Pages : 456 Slots : 1 Unix Shell Programming. shell, such as bash. Three are covered in the third edition of Unix Shell Programming. It begins with a generalized tutorial of Unix and tools and then moves into detailed coverage of shell programming. Topics. shell, such as bash. Three are covered in the third edition of Unix Shell Programming. It begins with a generalized tutorial of Unix and tools and then moves into detailed coverage of shell programming. Topics

Ngày đăng: 13/08/2014, 15:21

TỪ KHÓA LIÊN QUAN