Bash cookbook

Solo disponible en BuenasTareas
  • Páginas : 400 (99989 palabras )
  • Descarga(s) : 0
  • Publicado : 25 de noviembre de 2011
Leer documento completo
Vista previa del texto
bash Cookbook



Carl Albing, JP Vossen, and Cameron Newham

Beijing • Cambridge • Farnham • Köln • Paris • Sebastopol • Taipei • Tokyo

bash Cookbook™
by Carl Albing, JP Vossen, and Cameron Newham
Copyright © 2007 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/institutional sales department: (800) 998-9938 or corporate@oreilly.com.

Editor: Mike Loukides Production Editor: Laurel R.T. Ruma Copyeditor: Derek Di Matteo Production Services: Tolman CreekDesign Printing History:
May 2007: First Edition.

Cover Designer: Karen Montgomery Interior Designer: David Futato Illustrators: Robert Romano and Jessamyn Read

Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of O’Reilly Media, Inc. bash Cookbook, the image of a wood turtle, and related trade dress are trademarks of O’Reilly Media, Inc. Many ofthe 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 forerrors or omissions, or for damages resulting from the use of the information contained herein.

This book uses RepKover™ a durable and flexible lay-flat binding. , ISBN 10: 0-596-52678-4 ISNB 13: 978-0-596-52678-8 [M]

Table of Contents

Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii 1. Beginningbash . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 1.10 1.11 1.12 1.13 1.14 1.15 1.16 Decoding the Prompt Showing Where You Are Finding and Running Commands Getting Information About Files Showing All Hidden (dot) Files in the Current Directory Using Shell Quoting Using or Replacing Built-ins and ExternalCommands Determining If You Are Running Interactively Setting bash As Your Default Shell Getting bash for Linux Getting bash for xBSD Getting bash for Mac OS X Getting bash for Unix Getting bash for Windows Getting bash Without Getting bash Learning More About bash Documentation 4 5 6 8 10 12 13 15 16 17 20 21 22 23 24 25

2. Standard Output . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . . . . 28
2.1 2.2 2.3 2.4 2.5 2.6 Writing Output to the Terminal/Window Writing Output but Preserving Spacing Writing Output with More Formatting Control Writing Output Without the Newline Saving Output from a Command Saving Output to Other Files 29 30 31 32 33 34

iii

2.7 2.8 2.9 2.10 2.11 2.12 2.13 2.14 2.15 2.16 2.17 2.18 2.19 2.20 2.21 2.22Saving Output from the ls Command Sending Both Output and Error Messages to Different Files Sending Both Output and Error Messages to the Same File Appending Rather Than Clobbering Output Using Just the Beginning or End of a File Skipping a Header in a File Throwing Output Away Saving or Grouping Output from Several Commands Connecting Two Programs by Using Output As Input Saving a Copy of OutputEven While Using It As Input Connecting Two Programs by Using Output As Arguments Using Multiple Redirects on One Line Saving Output When Redirect Doesn’t Seem to Work Swapping STDERR and STDOUT Keeping Files Safe from Accidental Overwriting Clobbering a File on Purpose

35 37 37 39 39 40 41 41 43 44 46 47 48 50 52 53

3. Standard Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . ....
tracking img