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
1Activity
0 of .
Results for:
No results containing your search query
P. 1
Bash beginners Guide

Bash beginners Guide

Ratings: (0)|Views: 6|Likes:
Published by fulvio.mariola
Bash description for the shell
Bash description for the shell

More info:

Published by: fulvio.mariola on Nov 21, 2012
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

04/30/2014

pdf

text

original

 
Bash Guide for Beginners
Machtelt Garrels
Garrels BVBA
<tille wants no spam _at_ garrels dot be>
Version 1.11 Last updated 20081227 Edition
 
Table of Contents
Introduction.........................................................................................................................................................1
1. Why this guide?...................................................................................................................................12. Who should read this book?.................................................................................................................13. New versions, translationsand availability.........................................................................................24. Revision History..................................................................................................................................25. Contributions.......................................................................................................................................36. Feedback..............................................................................................................................................37. Copyright inf ormation.........................................................................................................................38. What do you need?...............................................................................................................................49. Conventions used in this document.....................................................................................................410. Organizationof this document...........................................................................................................5
Chapter 1. Bash and Bashscripts......................................................................................................................6
1.1. Common shell programs...................................................................................................................61.1.1. General shell functions............................................................................................................61.1.2. Shell types...............................................................................................................................61.2. Advantagesof the Bourne Again SHell............................................................................................71.2.1. Bash is the GNU shell.............................................................................................................71.2.2. Features only found in bash.....................................................................................................71.3. Executing commands......................................................................................................................121.3.1. General..................................................................................................................................121.3.2. Shell built-in commands........................................................................................................121.3.3. Executing programs from a script.........................................................................................131.4. Building blocks...............................................................................................................................131.4.1. Shell building blocks.............................................................................................................131.5. Developing good scripts.................................................................................................................151.5.1. Propertiesof good scripts......................................................................................................161.5.2. Structure................................................................................................................................161.5.3. Terminology..........................................................................................................................161.5.4. A word on order andlogic.....................................................................................................161.5.5. An example Bash script: mysystem.sh..................................................................................171.5.6. Example init script.................................................................................................................181.6. Summary.........................................................................................................................................191.7. Exercises.........................................................................................................................................19
Chapter 2. Writing and debugging scripts.....................................................................................................21
2.1. Creating and running a script..........................................................................................................212.1.1. Writing and naming...............................................................................................................212.1.2. script1.sh................................................................................................................................222.1.3. Executingthe script...............................................................................................................232.2. Script basics....................................................................................................................................242.2.1. Which shell will run the script?.............................................................................................242.2.2. Adding comments..................................................................................................................242.3. DebuggingBash scripts..................................................................................................................252.3.1. Debugging on the entire script..............................................................................................252.3.2. Debugging on part(s) of the script.........................................................................................262.4. Summary.........................................................................................................................................282.5. Exercises.........................................................................................................................................28
Bash Guide for Beginnersi
 
Table of Contents
Chapter 3. The Bash environment..................................................................................................................29
3.1. Shell initialization files...................................................................................................................293.1.1. System-wide configuration files............................................................................................293.1.2. Individualuser configuration files........................................................................................313.1.3. Changingshell configuration files........................................................................................333.2. Variables.........................................................................................................................................343.2.1. Types of variables.................................................................................................................343.2.2. Creating variables..................................................................................................................373.2.3. Exportingvariables................................................................................................................383.2.4. Reserved variables.................................................................................................................393.2.5. Special parameters.................................................................................................................413.2.6. Script recycling with variables..............................................................................................433.3. Quoting characters..........................................................................................................................443.3.1. Why?.....................................................................................................................................453.3.2. Escape characters..................................................................................................................453.3.3. Single quotes.........................................................................................................................453.3.4. Double quotes........................................................................................................................453.3.5. ANSI-C quoting....................................................................................................................463.3.6. Locales...................................................................................................................................463.4. Shell expansion...............................................................................................................................463.4.1. General..................................................................................................................................463.4.2. Brace expansion....................................................................................................................463.4.3. Tilde expansion.....................................................................................................................473.4.4. Shell parameter and variable expansion................................................................................473.4.5. Commandsubstitution...........................................................................................................483.4.6. Arithmetic expansion............................................................................................................493.4.7. Process substitution...............................................................................................................503.4.8. Word splitting........................................................................................................................503.4.9. File nameexpansion..............................................................................................................513.5. Aliases.............................................................................................................................................513.5.1. What arealiases?...................................................................................................................513.5.2. Creating and removing aliases..............................................................................................523.6. More Bashoptions..........................................................................................................................533.6.1. Displaying options.................................................................................................................533.6.2. Changing options...................................................................................................................543.7. Summary.........................................................................................................................................553.8. Exercises.........................................................................................................................................55
Chapter 4. Regular expressions.......................................................................................................................56
4.1. Regular expressions........................................................................................................................564.1.1. Whatare regular expressions?...............................................................................................564.1.2. Regular expression metacharacters.......................................................................................564.1.3. Basic versus extended regular expressions...........................................................................574.2. Examples using grep.......................................................................................................................574.2.1. What is grep?.........................................................................................................................574.2.2. Grep and regular expressions................................................................................................584.3. Pattern matching using Bash features.............................................................................................604.3.1. Character ranges....................................................................................................................60
Bash Guide for Beginnersii

You're Reading a Free Preview

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