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

Advanced Bash-Scripting Guide

Ratings: (0)|Views: 69 |Likes:
Published by Gianfranco
Advanced Bash Guide
Advanced Bash Guide

More info:

Published by: Gianfranco on Mar 01, 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/10/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.130 September 2009
Revision History
Revision 5.626 Jan 2009Revised by: mc'WORCESTERBERRY' release: Minor Update.Revision 6.023 Mar 2009Revised by: mc'THIMBLEBERRY' release: Major Update.Revision 6.130 Sep 2009Revised by: mc'BUFFALOBERRY' 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................................................................................................................................................51
7.1. Test Constructs...............................................................................................................................517.2. File test operators............................................................................................................................587.3. Other Comparison Operators..........................................................................................................617.4. Nestedif/then Condition Tests.......................................................................................................677.5. Testing Your Knowledgeof Tests..................................................................................................67
Chapter 8. Operations and Related Topics....................................................................................................69
8.1. Operators.........................................................................................................................................698.2. Numerical Constants.......................................................................................................................75
Part 3. Beyond the Basics.................................................................................................................................77Chapter 9. Variables Revisited........................................................................................................................78
9.1. Internal Variables............................................................................................................................789.2. Manipulating Strings.......................................................................................................................969.2.1. Manipulating strings using awk..........................................................................................1049.2.2. Further Reference................................................................................................................1049.3. Parameter Substitution..................................................................................................................1059.4. Typing variables: declare or typeset.............................................................................................1149.4.1. Another use for declare.......................................................................................................1169.5. Indirect References.......................................................................................................................1169.6. $RANDOM: generate random integer..........................................................................................1209.7. The Double-Parentheses Construct...............................................................................................131
Advanced Bash-Scripting Guidei
 
Table of Contents
Chapter 10. Loops andBranches..................................................................................................................134
10.1. Loops..........................................................................................................................................13410.2. Nested Loops..............................................................................................................................14710.3. Loop Control...............................................................................................................................14810.4. Testing and Branching................................................................................................................151
Chapter 11. Command Substitution.............................................................................................................160Chapter 12. Arithmetic Expansion................................................................................................................166Chapter 13. Recess Time................................................................................................................................167Part 4. Commands..........................................................................................................................................168Chapter 14. Internal Commands and Builtins.............................................................................................176
14.1. Job Control Commands..............................................................................................................205
Chapter 15. External Filters, Programs and Commands...........................................................................210
15.1. Basic Commands........................................................................................................................21015.2. Complex Commands...................................................................................................................21515.3. Time / Date Commands..............................................................................................................22515.4. Text Processing Commands........................................................................................................22915.5. File and Archiving Commands...................................................................................................25115.6. Communications Commands......................................................................................................27015.7. Terminal Control Commands.....................................................................................................28415.8. Math Commands.........................................................................................................................28515.9. Miscellaneous Commands..........................................................................................................296
Chapter 16. System and AdministrativeCommands..................................................................................310
16.1. Analyzing a System Script..........................................................................................................339
Part 5. Advanced Topics.................................................................................................................................341Chapter 17. Regular Expressions..................................................................................................................343
17.1. ABrief Introduction to Regular Expressions..............................................................................34317.2. Globbing.....................................................................................................................................347
Chapter 18. Here Documents.........................................................................................................................349
18.1. Here Strings................................................................................................................................359
Chapter 19. I/O Redirection...........................................................................................................................363
19.1. Using exec...................................................................................................................................36619.2. Redirecting Code Blocks............................................................................................................36919.3. Applications................................................................................................................................374
Chapter 20. Subshells.....................................................................................................................................376
Advanced Bash-Scripting Guideii

Activity (3)

You've already reviewed this. Edit your review.
1 hundred reads
sizweh liked this
sizweh liked this

You're Reading a Free Preview

Download
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->