Welcome to Scribd. Sign in or start your free trial to enjoy unlimited e-books, audiobooks & documents.Find out more
Download
Standard view
Full view
of .
Look up keyword
Like this
5Activity
0 of .
Results for:
No results containing your search query
P. 1
Advanced Bash Scripting Guide - Abs-guide

Advanced Bash Scripting Guide - Abs-guide

Ratings: (0)|Views: 252|Likes:
Published by hkeram

More info:

Published by: hkeram on Mar 23, 2010
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

08/21/2010

pdf

text

original

 
Advanced Bash-Scripting Guide
An in-depth exploration of the art of shell scripting
Mendel Cooper
<thegrendel.abs@gmail.com>
5.626 January 2009
Revision History
Revision 5.421 July 2008Revised by: mc'ANGLEBERRY' release: Major Update.Revision 5.523 Nov 2008Revised by: mc'FARKLEBERRY' release: Minor Update.Revision 5.626 Jan 2009Revised by: mc'WORCESTERBERRY' release: Minor Update.This tutorial assumes no previous knowledge of scripting or programming, but progresses rapidly toward anintermediate/advanced level of instruction
. . . all the while sneaking in little nuggets of UNIX® wisdom and lore
. It serves as a textbook, a manual for self-study, and a reference and source of knowledge on shellscripting techniques. The exercises and heavily-commented examples invite active reader participation, underthe premise that
the only way to really learn scripting is to write scripts
.This book is suitable for classroom use as a general introduction to programming concepts.
Dedication
For Anita, the source of all the magic
 
Table of Contents
Chapter 1. Why Shell Programming?...............................................................................................................1Chapter 2. Starting Off With a Sha-Bang........................................................................................................3
2.1. Invoking the script............................................................................................................................62.2. Preliminary Exercises.......................................................................................................................6
Part 2. Basics.......................................................................................................................................................7Chapter 3. Special Characters...........................................................................................................................8Chapter 4. Introduction to Variables and Parameters..................................................................................28
4.1. Variable Substitution......................................................................................................................284.2. Variable Assignment.......................................................................................................................314.3. Bash Variables Are Untyped..........................................................................................................324.4. Special Variable Types...................................................................................................................33
Chapter 5. Quoting...........................................................................................................................................39
5.1. Quoting Variables...........................................................................................................................395.2. Escaping..........................................................................................................................................41
Chapter 6. Exit and Exit Status.......................................................................................................................47Chapter 7. Tests................................................................................................................................................49
7.1. Test Constructs...............................................................................................................................497.2. File test operators............................................................................................................................567.3. Other Comparison Operators..........................................................................................................597.4. Nestedif/then Condition Tests.......................................................................................................647.5. Testing Your Knowledgeof Tests..................................................................................................65
Chapter 8. Operations and Related Topics....................................................................................................66
8.1. Operators.........................................................................................................................................668.2. Numerical Constants.......................................................................................................................72
Part 3. Beyond the Basics.................................................................................................................................74Chapter 9. Variables Revisited........................................................................................................................75
9.1. Internal Variables............................................................................................................................759.2. Manipulating Strings.......................................................................................................................929.2.1. Manipulating strings using awk..........................................................................................1009.2.2. Further Reference................................................................................................................1009.3. Parameter Substitution..................................................................................................................1019.4. Typing variables: declare or typeset.............................................................................................1109.4.1. Another use for declare.......................................................................................................1129.5. Indirect References.......................................................................................................................1139.6. $RANDOM: generate random integer..........................................................................................1169.7. The Double-Parentheses Construct...............................................................................................127
Advanced Bash-Scripting Guidei
 
Table of Contents
Chapter 10. Loops andBranches..................................................................................................................129
10.1. Loops..........................................................................................................................................12910.2. Nested Loops..............................................................................................................................14210.3. Loop Control...............................................................................................................................14310.4. Testing and Branching................................................................................................................146
Chapter 11. Command Substitution.............................................................................................................155Chapter 12. Arithmetic Expansion................................................................................................................161Chapter 13. Recess Time................................................................................................................................162Part 4. Commands..........................................................................................................................................163Chapter 14. Internal Commands and Builtins.............................................................................................171
14.1. Job Control Commands..............................................................................................................199
Chapter 15. External Filters, Programs and Commands...........................................................................204
15.1. Basic Commands........................................................................................................................20415.2. Complex Commands...................................................................................................................20915.3. Time / Date Commands..............................................................................................................21915.4. Text Processing Commands........................................................................................................22315.5. File and Archiving Commands...................................................................................................24515.6. Communications Commands......................................................................................................26315.7. Terminal Control Commands.....................................................................................................27715.8. Math Commands.........................................................................................................................27815.9. Miscellaneous Commands..........................................................................................................289
Chapter 16. System and AdministrativeCommands..................................................................................303
16.1. Analyzing a System Script..........................................................................................................332
Part 5. Advanced Topics.................................................................................................................................334Chapter 17. Regular Expressions..................................................................................................................336
17.1. ABrief Introduction to Regular Expressions..............................................................................33617.2. Globbing.....................................................................................................................................340
Chapter 18. Here Documents.........................................................................................................................342
18.1. Here Strings................................................................................................................................352
Chapter 19. I/O Redirection...........................................................................................................................355
19.1. Using exec...................................................................................................................................35819.2. Redirecting Code Blocks............................................................................................................36119.3. Applications................................................................................................................................366
Chapter 20. Subshells.....................................................................................................................................368
Advanced Bash-Scripting Guideii

Activity (5)

You've already reviewed this. Edit your review.
1 thousand reads
1 hundred reads
sura2k liked this
nagmut liked this
supratik_sekhar liked this

You're Reading a Free Preview

Download