Oreilly.Classic.Shell.Scripting.May.2005.pdf

(7851 KB) Pobierz
827183796.011.png
827183796.012.png
Classic Shell Scripting
Arnold Robbins and Nelson H. F. Beebe
Beijing
Cambridge
Farnham
Köln
Sebastopol
Tokyo
827183796.013.png 827183796.014.png 827183796.001.png 827183796.002.png 827183796.003.png 827183796.004.png 827183796.005.png 827183796.006.png
Classic Shell Scripting
by Arnold Robbins and Nelson H. F. Beebe
Copyright © 2005 O’Reilly Media, Inc. All rights reserved.
Printed in the United States of America.
Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472.
O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions
are also available for most titles ( safari.oreilly.com ). For more information,contact our corporate/insti-
tutional sales department: (800) 998-9938 or corporate@oreilly.com .
Editors:
Tatiana Apandi
Allison Randal
Production Editor:
Adam Witwer
Cover Designer:
Emma Colby
Interior Designer:
David Futato
Printing History:
May 2005:
First Edition.
Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of
O’Reilly Media,Inc. Classic Shell Scripting ,the image of a African tent tortoise,and related trade dress
are trademarks of O’Reilly Media, 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 Media, Inc. was aware of a
trademark claim, the designations have been printed in caps or initial caps.
While every precaution has been taken in the preparation of this book, the publisher and authors
assume no responsibility for errors or omissions, or for damages resulting from the use of the
information contained herein.
ISBN: 978-0-596-00595-5
[LSI]
[2011-03-11]
827183796.007.png
Table of Contents
Foreword
ix
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Preface
xi
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.
Background
1
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.1 Unix History
1
1.2 Software Tools Principles
4
1.3 Summary
6
2.
Getting Started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8
2.1 Scripting Languages Versus Compiled Languages
8
2.2 Why Use a Shell Script?
9
2.3 A Simple Script
9
2.4 Self-Contained Scripts: The #! First Line
10
2.5 Basic Shell Constructs
12
2.6 Accessing Shell Script Arguments
23
2.7 Simple Execution Tracing
24
2.8 Internationalization and Localization
25
2.9 Summary
28
3.
Searching and Substitutions
30
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.1 Searching for Text
30
3.2 Regular Expressions
31
3.3 Working with Fields
56
3.4 Summary
65
iii
827183796.008.png 827183796.009.png 827183796.010.png
 
Zgłoś jeśli naruszono regulamin