classic_shell_scripting.pdf

(7693 KB) Pobierz
Classic Shell Scripting
Arnold Robbins and Nelson H. F. Beebe
Beijing
Cambridge
Farnham
Köln
Sebastopol
Tokyo
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:
Production Editor:
Cover Designer:
Interior Designer:
Printing History:
May 2005:
Tatiana Apandi
Allison Randal
Adam Witwer
Emma Colby
David Futato
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]
Table of Contents
Foreword
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
ix
Preface
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
xi
1. Background
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1
1.1 Unix History
1.2 Software Tools Principles
1.3 Summary
1
4
6
2. Getting Started
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8
2.1
2.2
2.3
2.4
2.5
2.6
2.7
2.8
2.9
Scripting Languages Versus Compiled Languages
Why Use a Shell Script?
A Simple Script
Self-Contained Scripts: The #! First Line
Basic Shell Constructs
Accessing Shell Script Arguments
Simple Execution Tracing
Internationalization and Localization
Summary
8
9
9
10
12
23
24
25
28
3. Searching and Substitutions
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
30
3.1
3.2
3.3
3.4
Searching for Text
Regular Expressions
Working with Fields
Summary
30
31
56
65
iii
Zgłoś jeśli naruszono regulamin