Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more ➡
Download
Standard view
Full view
of .
Add note
Save to My Library
Sync to mobile
Look up keyword
Like this
7Activity
×
0 of .
Results for:
No results containing your search query
P. 1
Advanced Bash-Scripting Guide

Advanced Bash-Scripting Guide

Ratings: (0)|Views: 275|Likes:
Published by vagner4work
Advanced Bash-Scripting Guide
Advanced Bash-Scripting Guide

More info:

Published by: vagner4work on Aug 12, 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

12/12/2012

pdf

text

original

 
Advanced Bash-Scripting Guide
An in-depth exploration of the art of shell scripting
Mendel Cooper
<thegrendel.abs@gmail.com>
6.0.0524 March 2009
Revision History
Revision 5.523 Nov 2008Revised by: mc'FARKLEBERRY' release: Minor Update.Revision 5.626 Jan 2009Revised by: mc'WORCESTERBERRY' release: Minor Update.Revision 6.023 Mar 2009Revised by: mc'THIMBLEBERRY' 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. 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..................................................................................29
4.1. Variable Substitution......................................................................................................................294.2. Variable Assignment.......................................................................................................................324.3. Bash Variables Are Untyped..........................................................................................................334.4. Special Variable Types...................................................................................................................34
Chapter 5. Quoting...........................................................................................................................................40
5.1. Quoting Variables...........................................................................................................................405.2. Escaping..........................................................................................................................................42
Chapter 6. Exit and Exit Status.......................................................................................................................48Chapter 7. Tests................................................................................................................................................50
7.1. Test Constructs...............................................................................................................................507.2. File test operators............................................................................................................................577.3. Other Comparison Operators..........................................................................................................607.4. Nestedif/then Condition Tests.......................................................................................................657.5. Testing Your Knowledgeof Tests..................................................................................................66
Chapter 8. Operations and Related Topics....................................................................................................67
8.1. Operators.........................................................................................................................................678.2. Numerical Constants.......................................................................................................................73
Part 3. Beyond the Basics.................................................................................................................................75Chapter 9. Variables Revisited........................................................................................................................76
9.1. Internal Variables............................................................................................................................769.2. Manipulating Strings.......................................................................................................................949.2.1. Manipulating strings using awk..........................................................................................1019.2.2. Further Reference................................................................................................................1029.3. Parameter Substitution..................................................................................................................1029.4. Typing variables: declare or typeset.............................................................................................1119.4.1. Another use for declare.......................................................................................................1149.5. Indirect References.......................................................................................................................1149.6. $RANDOM: generate random integer..........................................................................................1179.7. The Double-Parentheses Construct...............................................................................................129
Advanced Bash-Scripting Guidei
 
Table of Contents
Chapter 10. Loops andBranches..................................................................................................................131
10.1. Loops..........................................................................................................................................13110.2. Nested Loops..............................................................................................................................14410.3. Loop Control...............................................................................................................................14510.4. Testing and Branching................................................................................................................148
Chapter 11. Command Substitution.............................................................................................................157Chapter 12. Arithmetic Expansion................................................................................................................163Chapter 13. Recess Time................................................................................................................................164Part 4. Commands..........................................................................................................................................165Chapter 14. Internal Commands and Builtins.............................................................................................173
14.1. Job Control Commands..............................................................................................................202
Chapter 15. External Filters, Programs and Commands...........................................................................207
15.1. Basic Commands........................................................................................................................20715.2. Complex Commands...................................................................................................................21215.3. Time / Date Commands..............................................................................................................22215.4. Text Processing Commands........................................................................................................22615.5. File and Archiving Commands...................................................................................................24815.6. Communications Commands......................................................................................................26615.7. Terminal Control Commands.....................................................................................................28015.8. Math Commands.........................................................................................................................28115.9. Miscellaneous Commands..........................................................................................................292
Chapter 16. System and AdministrativeCommands..................................................................................306
16.1. Analyzing a System Script..........................................................................................................335
Part 5. Advanced Topics.................................................................................................................................337Chapter 17. Regular Expressions..................................................................................................................339
17.1. ABrief Introduction to Regular Expressions..............................................................................33917.2. Globbing.....................................................................................................................................343
Chapter 18. Here Documents.........................................................................................................................345
18.1. Here Strings................................................................................................................................355
Chapter 19. I/O Redirection...........................................................................................................................358
19.1. Using exec...................................................................................................................................36119.2. Redirecting Code Blocks............................................................................................................36419.3. Applications................................................................................................................................369
Chapter 20. Subshells.....................................................................................................................................371
Advanced Bash-Scripting Guideii

Activity (7)

You've already reviewed this. Edit your review.
1 hundred reads
aslasem liked this
BGSorin liked this
daver2tarleton liked this
Poie liked this
marceloedy liked this
marceloedy liked this

You're Reading a Free Preview

Download