bash_cookbook.pdf

(7123 KB) Pobierz
2n
d
Ed
iti
on
Cookbook
SOLUTIONS AND EXAMPLES FOR BASH USERS
bash
Carl Albing & JP Vossen
SECOND EDITION
Solutions and Examples for bash Users
bash Cookbook
Carl Albing and JP Vossen
bash Cookbook
by Carl Albing and JP Vossen
Copyright © 2018 Carl Albing and JP Vossen. 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 (http://oreilly.com/safari). For more information, contact our corporate/insti‐
tutional sales department: 800-998-9938 or
corporate@oreilly.com.
Editor:
Jeff Bleiel
Production Editor:
Kristen Brown
Copyeditor:
Rachel Head
Proofreader:
James Fraleigh
May 2007:
October 2017:
First Edition
Second Edition
Indexer:
Ellen Troutman-Zaig
Interior Designer:
David Futato
Cover Designer:
Karen Montgomery
Illustrator:
Rebecca Demarest
Revision History for the Second Edition
2017-10-04:
First Release
See
http://oreilly.com/catalog/errata.csp?isbn=9781491975336
for release details.
The O’Reilly logo is a registered trademark of O’Reilly Media, Inc.
bash Cookbook,
the cover image, and
related trade dress are trademarks of O’Reilly Media, Inc.
While the publisher and the authors have used good faith efforts to ensure that the information and
instructions contained in this work are accurate, the publisher and the authors disclaim all responsibility
for errors or omissions, including without limitation responsibility for damages resulting from the use of
or reliance on this work. Use of the information and instructions contained in this work is at your own
risk. If any code samples or other technology this work contains or describes is subject to open source
licenses or the intellectual property rights of others, it is your responsibility to ensure that your use
thereof complies with such licenses and/or rights.
978-1-491-97533-6
[LSI]
Table of Contents
Preface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii
1. Beginning bash. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1 Why bash?
1.2 The bash Shell
1.3 Decoding the Prompt
1.4 Showing Where You Are
1.5 Finding and Running Commands
1.6 Getting Information About Files
1.7 Showing All Hidden (Dot) Files in the Current Directory
1.8 Using Shell Quoting
1.9 Using or Replacing Builtins and External Commands
1.10 Determining if You Are Running Interactively
1.11 Setting bash as Your Default Shell
1.12 Keeping bash Updated
1.13 Getting bash for Linux
1.14 Getting bash for xBSD
1.15 Getting bash for macOS
1.16 Getting bash for Unix
1.17 Getting bash for Windows
1.18 Getting bash Without Getting bash
1.19 Learning More About bash Documentation
2.1 Writing Output to the Terminal/Window
2.2 Writing Output but Preserving Spacing
2.3 Writing Output with More Formatting Control
2.4 Writing Output Without the Newline
2
3
4
5
6
8
11
13
15
17
18
20
21
22
24
24
26
29
30
34
35
36
38
iii
2. Standard Output. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Zgłoś jeśli naruszono regulamin