Pro_Bash_programming_scripting_the_gnu_Linux_shell.pdf

(5339 KB) Pobierz
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
The eXperT’s VoiCe ® in linuX
Covering
Bash 4.0
Pro
Bash
Programming
Scripting the GNU/Linux Shell
Programming bash from one-liners
to professional programs
Chris F.A. Johnson
840461697.095.png 840461697.103.png 840461697.113.png
 
 
 
 
 
 
 
840461697.055.png
 
840461697.070.png 840461697.071.png 840461697.072.png 840461697.073.png 840461697.074.png 840461697.075.png 840461697.076.png 840461697.077.png
 
 
 
 
 
 
 
 
 
 
 
 
840461697.078.png
 
 
 
840461697.079.png 840461697.080.png 840461697.081.png 840461697.082.png 840461697.083.png 840461697.084.png 840461697.085.png 840461697.086.png 840461697.087.png 840461697.088.png 840461697.089.png 840461697.090.png 840461697.091.png 840461697.092.png
 
840461697.093.png
 
840461697.094.png
 
840461697.096.png
 
840461697.097.png
 
840461697.098.png 840461697.099.png 840461697.100.png 840461697.101.png 840461697.102.png 840461697.104.png 840461697.105.png 840461697.106.png 840461697.107.png 840461697.108.png 840461697.109.png
 
840461697.110.png 840461697.111.png 840461697.112.png 840461697.114.png 840461697.115.png 840461697.116.png 840461697.117.png 840461697.118.png 840461697.119.png 840461697.120.png 840461697.121.png 840461697.122.png 840461697.123.png 840461697.124.png 840461697.125.png 840461697.126.png 840461697.127.png 840461697.128.png 840461697.129.png 840461697.130.png 840461697.131.png
 
840461697.132.png 840461697.001.png 840461697.002.png 840461697.003.png 840461697.004.png 840461697.005.png 840461697.006.png 840461697.007.png 840461697.008.png 840461697.009.png 840461697.010.png
 
 
840461697.011.png 840461697.012.png
 
840461697.013.png 840461697.014.png
 
840461697.015.png 840461697.016.png 840461697.017.png 840461697.018.png 840461697.019.png 840461697.020.png 840461697.021.png 840461697.022.png 840461697.023.png 840461697.024.png
 
 
840461697.025.png 840461697.026.png 840461697.027.png 840461697.028.png 840461697.029.png 840461697.030.png 840461697.031.png 840461697.032.png 840461697.033.png 840461697.034.png 840461697.035.png 840461697.036.png 840461697.037.png 840461697.038.png 840461697.039.png 840461697.040.png 840461697.041.png 840461697.042.png 840461697.043.png 840461697.044.png 840461697.045.png 840461697.046.png 840461697.047.png 840461697.048.png 840461697.049.png 840461697.050.png 840461697.051.png 840461697.052.png 840461697.053.png 840461697.054.png 840461697.056.png 840461697.057.png 840461697.058.png
 
CONTENTS
Pro Bash Programming
Scripting the GNU/Linux Shell
Chris F.A. Johnson
i
840461697.059.png 840461697.060.png 840461697.061.png 840461697.062.png 840461697.063.png 840461697.064.png 840461697.065.png 840461697.066.png
CONENTS
Pro Bash Programming: Scripting the GNU/Linux Shell
Copyright © 2009 by Chris F.A. Johnson
All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means,
electronic or mechanical, including photocopying, recording, or by any information storage or retrieval
system, without the prior written permission of the copyright owner and the publisher.
ISBN-13 (pbk): 978-1-4302-1997-2
ISBN-13 (electronic): 978-1-4302-1998-9
Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1
Trademarked names may appear in this book. Rather than use a trademark symbol with every
occurrence of a trademarked name, we use the names only in an editorial fashion and to the benefit of
the trademark owner, with no intention of infringement of the trademark.
Lead Editor: Frank Pohlmann
Technical Reviewer: Ed Schaefer
Editorial Board: Clay Andres, Steve Anglin, Mark Beckner, Ewan Buckingham, Tony Campbell,
Gary Cornell, Jonathan Gennick, Jonathan Hassell, Michelle Lowman, Matthew Moodie,
Jeffrey Pepper, Frank Pohlmann, Douglas Pundick, Ben Renow-Clarke, Dominic Shakeshaft,
Matt Wade, Tom Welsh
Project Manager: Kylie Johnston
Copy Editor: Kim Wimpsett
Compositor: ContentWorks, Inc.
Indexer: Julie Grady
Distributed to the book trade worldwide by Springer-Verlag New York, Inc., 233 Spring Street, 6th Floor,
New York, NY 10013. Phone 1-800-SPRINGER, fax 201-348-4505, e-mail orders-ny@springer-sbm.com , or
visit http://www.springeronline.com .
For information on translations, please contact Apress directly at 233 Spring Street, New York, NY 10013.
E-mail info@apress.com , or visit http://www.apress.com .
Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional use.
eBook versions and licenses are also available for most titles. For more information, reference our
Special Bulk Sales–eBook Licensing web page at http://www.apress.com/info/bulksales .
The information in this book is distributed on an “as is” basis, without warranty. Although every
precaution has been taken in the preparation of this work, neither the author(s) nor Apress shall have
any liability to any person or entity with respect to any loss or damage caused or alleged to be caused
directly or indirectly by the information contained in this work.
The source code for this book is available to readers at http://www.apress.com .
ii
840461697.067.png 840461697.068.png
CONTENTS
Contents at a Glance
About the Author................................................................................................... xvi
About the Technical Reviewer ............................................................................. xvii
Introduction .......................................................................................................... xix
Chapter 1: Hello, World! Your First Shell Program ..................................................1
Chapter 2: Input, Output, and Throughput ...............................................................7
Chapter 3: Looping and Branching ........................................................................19
Chapter 4: Command-Line Parsing and Expansion...............................................29
Chapter 5: Parameters and Variables....................................................................43
Chapter 6: Shell Functions.....................................................................................59
Chapter 7: String Manipulation..............................................................................67
Chapter 8: File Operations and Commands ...........................................................79
Chapter 9: Reserved Words and Builtin Commands .............................................97
Chapter 10: Writing Bug-Free Scripts and Debugging the Rest..........................113
Chapter 11: Programming for the Command Line ..............................................125
Chapter 12: Runtime Configuration .....................................................................141
Chapter 13: Data Processing ...............................................................................157
Chapter 14: Scripting the Screen.........................................................................179
Chapter 15: Entry-Level Programming ................................................................191
Appendix: Shell Variables ....................................................................................205
Index ....................................................................................................................221
iii
840461697.069.png
Zgłoś jeśli naruszono regulamin