24.07.2018 Views

Bash-Beginners-Guide

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Bash</strong> <strong>Guide</strong> for <strong>Beginners</strong><br />

Table of Contents<br />

Chapter 3. The <strong>Bash</strong> environment..................................................................................................................29<br />

3.1. Shell initialization files...................................................................................................................29<br />

3.1.1. System-wide configuration files............................................................................................29<br />

3.1.2. Individual user configuration files........................................................................................31<br />

3.1.3. Changing shell configuration files........................................................................................33<br />

3.2. Variables.........................................................................................................................................34<br />

3.2.1. Types of variables.................................................................................................................34<br />

3.2.2. Creating variables..................................................................................................................37<br />

3.2.3. Exporting variables................................................................................................................38<br />

3.2.4. Reserved variables.................................................................................................................39<br />

3.2.5. Special parameters.................................................................................................................41<br />

3.2.6. Script recycling with variables..............................................................................................43<br />

3.3. Quoting characters..........................................................................................................................44<br />

3.3.1. Why?.....................................................................................................................................45<br />

3.3.2. Escape characters..................................................................................................................45<br />

3.3.3. Single quotes.........................................................................................................................45<br />

3.3.4. Double quotes........................................................................................................................45<br />

3.3.5. ANSI-C quoting....................................................................................................................46<br />

3.3.6. Locales...................................................................................................................................46<br />

3.4. Shell expansion...............................................................................................................................46<br />

3.4.1. General..................................................................................................................................46<br />

3.4.2. Brace expansion....................................................................................................................46<br />

3.4.3. Tilde expansion.....................................................................................................................47<br />

3.4.4. Shell parameter and variable expansion................................................................................47<br />

3.4.5. Command substitution...........................................................................................................48<br />

3.4.6. Arithmetic expansion............................................................................................................49<br />

3.4.7. Process substitution...............................................................................................................50<br />

3.4.8. Word splitting........................................................................................................................50<br />

3.4.9. File name expansion..............................................................................................................51<br />

3.5. Aliases.............................................................................................................................................51<br />

3.5.1. What are aliases?...................................................................................................................51<br />

3.5.2. Creating and removing aliases..............................................................................................52<br />

3.6. More <strong>Bash</strong> options..........................................................................................................................53<br />

3.6.1. Displaying options.................................................................................................................53<br />

3.6.2. Changing options...................................................................................................................54<br />

3.7. Summary.........................................................................................................................................55<br />

3.8. Exercises.........................................................................................................................................55<br />

Chapter 4. Regular expressions.......................................................................................................................56<br />

4.1. Regular expressions........................................................................................................................56<br />

4.1.1. What are regular expressions?...............................................................................................56<br />

4.1.2. Regular expression metacharacters.......................................................................................56<br />

4.1.3. Basic versus extended regular expressions...........................................................................57<br />

4.2. Examples using grep.......................................................................................................................57<br />

4.2.1. What is grep?.........................................................................................................................57<br />

4.2.2. Grep and regular expressions................................................................................................58<br />

4.3. Pattern matching using <strong>Bash</strong> features.............................................................................................60<br />

4.3.1. Character ranges....................................................................................................................60<br />

ii

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!