bash.Cookbook.pdf

(2099 KB) Pobierz
bash Cookbook
728008619.002.png
728008619.003.png
bash Cookbook
Carl Albing, JP Vossen, and Cameron Newham
Beijing Cambridge Farnham Köln Paris Sebastopol Taipei Tokyo
728008619.004.png
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 Creek Design
Cover Designer: Karen Montgomery
Interior Designer: David Futato
Illustrators: Robert Romano and Jessamyn Read
Printing History:
May 2007:
First Edition.
Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of
O’ReillyMedia,Inc. bash Cookbook ,theimageofawoodturtle,andrelatedtradedressaretrademarks
of O’Reilly Media, Inc.
Manyofthedesignationsusedbymanufacturersandsellerstodistinguishtheirproductsareclaimedas
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.
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]
728008619.005.png
Table of Contents
Preface
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii
1. Beginning bash
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1
1.1 Decoding the Prompt
4
1.2 Showing Where You Are
5
1.3 Finding and Running Commands
6
1.4 Getting Information About Files
8
1.5 Showing All Hidden (dot) Files in the Current Directory
10
1.6 Using Shell Quoting
12
1.7 Using or Replacing Built-ins and External Commands
13
1.8 Determining If You Are Running Interactively
15
1.9 Setting bash As Your Default Shell
16
1.10 Getting bash for Linux
17
1.11 Getting bash for xBSD
20
1.12 Getting bash for Mac OS X
21
1.13 Getting bash for Unix
22
1.14 Getting bash for Windows
23
1.15 Getting bash Without Getting bash
24
1.16 Learning More About bash Documentation
25
2. Standard Output
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
28
2.1 Writing Output to the Terminal/Window
29
2.2 Writing Output but Preserving Spacing
30
2.3 Writing Output with More Formatting Control
31
2.4 Writing Output Without the Newline
32
2.5 Saving Output from a Command
33
2.6 Saving Output to Other Files
34
iii
728008619.001.png
 
Zgłoś jeśli naruszono regulamin