Transcription of Learning the bash Shell, 3rd Edition - Lagout.org
1 1 Learning the bash Shell, 3rd EditionTable of Contents2 Prefacebash VersionsSummary of bash FeaturesIntended AudienceCode ExamplesChapter SummaryConventions Used in This HandbookWe'd Like to Hear from YouUsing Code ExamplesSafari EnabledAcknowledgments for the First EditionAcknowledgments for the Second EditionAcknowledgments for the Third Edition1. bash What Is a Shell? Scope of This History of UNIX The Bourne Again Features of Getting Interactive Shell Commands, Arguments, and Filenames, Wildcards, and Brace Input and Standard I/O Background Background Background Jobs and Special Characters and Quoting Quotation Continuing Control Help2.
2 Command-Line Enabling Command-Line The History emacs Editing Basic Word Line Moving Around in the History Textual Miscellaneous vi Editing Simple Control Mode Entering and Changing Deletion Moving Around in the History Character-Finding Textual Miscellaneous The fc History The readline Startup Key Bindings Using Keyboard Habits3. Customizing Your The .bash_profile, .bash_logout, and . Shell Variables and Built-In Customization and Environment The Environment Customization Hints4.
3 Basic Shell Shell Scripts and Shell Positional Local Variables in Quoting with $@ and $* More on Variable String Syntax of String Patterns and Pattern Length Extended Pattern Command Advanced Examples: pushd and popd5. Flow Exit Combinations of Exit Condition Integer while and until6. Command-Line Options and Typed Command-Line Options with Typed Integer Variables and Arithmetic Arithmetic Variables and Arithmetic for Arrays7. Input/Output and Command-Line I/O File String Command-Line command, builtin, and eval8.
4 Process Process IDs and Job Job Foreground and Suspending a Control-Key Traps and Process ID Variables and Ignoring Resetting Advantages and Disadvantages Subshell Nested Process Substitution9. Debugging Shell Basic Debugging Set Fake Debugging A bash Structure of the The Debugger A Sample bashdb Exercises10. bash Installing bash as the Standard POSIX Command-Line Environment Types of Global System Security Restricted A System Break-In Privileged Mode11.
5 Shell What's That Do? Variables and Starting Potential Don't Use bash12. bash for Your Obtaining Unpacking the What's in the Configuring and Building Testing Potential Installing bash as a Login Who Do I Turn to? Asking Reporting BugsA. Related The Bourne The IEEE POSIX Shell The Korn Shell Clones and Unix-like MKS AT&T UWINB. Reference Prompt String Built-In Commands and Reserved Built-In Shell Test set shopt I/O emacs Mode vi Control Mode CommandsC. Loadable Built-InsD.
6 Programmable Completion12 Learning the bash Shell, 3rd EditionCameron NewhamCopyright 2009 O'Reilly Media, 'Reilly Media, first thing users of the UNIX or Linux operatingsystems come face to face with is theshell. "Shell" is theUNIX term for a user interface to the system somethingthat lets you communicate with the computer via thekeyboard and the display. Shells are just separateprograms that encapsulate the system, and, as such, thereare many to choose are usually set up with a "standard" shell thatnew users adopt without question.
7 However, some ofthese standard shells are rather old and lack manyfeatures of the newer shells. This is a shame, becauseshells have a large bearing on your working changing shells is as easy as changing hats, there isno reason not to change to the latest and greatest in the many shells to choose from, this book introducesthe Bourne Again shell (bashfor short), a moderngeneral-purpose shell. Other useful modern shells are theKorn shell (ksh) and the "Tenex C shell" (tcsh); both arealso the subjects of O'Reilly VersionsThis book is relevant to all versions ofbash, althougholder versions lack some of the features of the mostrecent version.
8 [1]You can easily find out which versionyou are using by typingecho $BASH_VERSION. Theearliest public version ofbashwas , and the mostrecent is (released in July 2004). If you have an olderversion, you might like to upgrade to the latest 12shows you how to go about it.[1]Throughout this book we have clearly marked withfootnotes the features that are not present in the a backward-compatible evolutionary successor tothe Bourne shell that includes most of the C shell's majoradvantages as well as features from the Korn shell and afew new features of its own.
9 Features appropriated fromthe C shell include: Directory manipulation, with thepushd,popd,anddirscommands. Job control, including thefgandbgcommandsand the ability to stop jobs with CTRL-Z. Brace expansion, for generating arbitrary strings. Tilde expansion, a shorthand way to refer todirectories. Aliases, which allow you to define shorthandnames for commands or command lines. Commandhistory,whichletsyourecallpreviou sly entered 's major new features include:16 Command-line editing, allowing you to usevi- oremacs-style editing commands on your commandlines.
10 Key bindings that allow you to set up customizedediting key sequences. Integratedprogrammingfeatures:thefunctio nalityofseveralexternalUNIX commands, includingtest,expr,getopt, andecho,has been integrated into the shell itself, enablingcommon programming tasks to be done morecleanly and efficiently. Control structures, especially theselectconstruct,which enables easy menu generation. New options and variables that give you moreways to customize your environment. Onedimensionalarraysthatalloweasyreferen cing and manipulation of lists of data.