Flylib.com

Books Software

 
 
 

Copyright

 < Day Day Up > 

Copyright 2005, 1998, 1995 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 (http://safari.oreilly.com). For more information, contact our corporate/institutional sales department: (800) 998-9938 or corporate@oreilly.com.

Nutshell Handbook, the Nutshell Handbook logo, and the O'Reilly logo are registered trademarks of O'Reilly Media, Inc. Learning the bash Shell , the image of a silver bass, 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.

 < Day Day Up > 
 < Day Day Up > 

Preface

The first thing users of the UNIX or Linux operating systems come face to face with is the shell . "Shell" is the UNIX term for a user interface to the system—something that lets you communicate with the computer via the keyboard and the display. Shells are just separate programs that encapsulate the system, and, as such, there are many to choose from.

Systems are usually set up with a "standard" shell that new users adopt without question. However, some of these standard shells are rather old and lack many features of the newer shells. This is a shame, because shells have a large bearing on your working environment. Since changing shells is as easy as changing hats, there is no reason not to change to the latest and greatest in shell technology.

Of the many shells to choose from, this book introduces the Bourne Again shell ( bash for short), a modern general-purpose shell. Other useful modern shells are the Korn shell ( ksh ) and the "Tenex C shell" ( tcsh ); both are also the subjects of O'Reilly handbooks.

 < Day Day Up > 
 < Day Day Up > 

bash Versions

This book is relevant to all versions of bash , although older versions lack some of the features of the most recent version. [1] You can easily find out which version you are using by typing echo $BASH_VERSION . The earliest public version of bash was 1.0, and the most recent is 3.0 (released in July 2004). If you have an older version, you might like to upgrade to the latest one. Chapter 12 shows you how to go about it.

[1] Throughout this book we have clearly marked with footnotes the features that are not present in the earlier versions.

 < Day Day Up > 
 < Day Day Up > 

Summary of bash Features

bash is a backward-compatible evolutionary successor to the Bourne shell that includes most of the C shell's major advantages as well as features from the Korn shell and a few new features of its own. Features appropriated from the C shell include:

  • Directory manipulation, with the pushd , popd , and dirs commands.

  • Job control, including the fg and bg commands and the ability to stop jobs with CTRL-Z.

  • Brace expansion, for generating arbitrary strings.

  • Tilde expansion, a shorthand way to refer to directories.

  • Aliases, which allow you to define shorthand names for commands or command lines.

  • Command history, which lets you recall previously entered commands.

bash 's major new features include:

  • Command-line editing, allowing you to use vi - or emacs -style editing commands on your command lines.

  • Key bindings that allow you to set up customized editing key sequences.

  • Integrated programming features: the functionality of several external UNIX commands, including test , expr , getopt , and echo , has been integrated into the shell itself, enabling common programming tasks to be done more cleanly and efficiently .

  • Control structures, especially the select construct, which enables easy menu generation.

  • New options and variables that give you more ways to customize your environment.

  • One dimensional arrays that allow easy referencing and manipulation of lists of data.

  • Dynamic loading of built-ins , plus the ability to write your own and load them into the running shell.

 < Day Day Up >