/ Linux Reviews / Beginners: Learn Linux / Bash Guide for Beginners - en


Bash Guide for Beginners

Machtelt Garrels

CoreSequence.com

Table of Contents
Introduction
1. Why this guide?
2. Who should read this book?
3. New versions of this guide
4. Revision History
5. Contributions
6. Feedback
7. Copyright information
8. What do you need?
9. Conventions used in this document
10. Organization of this document
1. Bash and Bash scripts
1.1. Common shell programs
1.1.1. General shell functions
1.1.2. Shell types
1.2. Advantages of the Bourne Again SHell
1.2.1. Bash is the GNU shell
1.2.2. Features only found in bash
1.3. Executing commands
1.3.1. General
1.3.2. Shell built-in commands
1.3.3. Executing programs from a script
1.4. Building blocks
1.4.1. Shell building blocks
1.5. Developing good scripts
1.5.1. Properties of good scripts
1.5.2. Structure
1.5.3. Terminology
1.5.4. A word on order and logic
1.5.5. An example Bash script: mysystem.sh
1.5.6. Example init script
1.6. Summary
1.7. Exercises
2. Writing and debugging scripts
2.1. Creating and running a script
2.1.1. Writing and naming
2.1.2. script1.sh
2.1.3. Executing the script
2.2. Script basics
2.2.1. Which shell will run the script?
2.2.2. Adding comments
2.3. Debugging Bash scripts
2.3.1. Debugging on the entire script
2.3.2. Debugging on part(s) of the script
2.4. Summary
2.5. Exercises
3. The Bash environment
3.1. Shell initialization files
3.1.1. System-wide configuration files
3.1.2. Individual user configuration files
3.1.3. Changing shell configuration files
3.2. Variables
3.2.1. Types of variables
3.2.2. Creating variables
3.2.3. Exporting variables
3.2.4. Reserved variables
3.2.5. Special parameters
3.3. Quoting characters
3.3.1. Why?
3.3.2. Escape characters
3.3.3. Single quotes
3.3.4. Double quotes
3.3.5. ANSI-C quoting
3.3.6. Locales
3.4. Shell expansion
3.4.1. General
3.4.2. Brace expansion
3.4.3. Tilde expansion
3.4.4. Shell parameter and variable expansion
3.4.5. Command substitution
3.4.6. Arithmetic expansion
3.4.7. Process substitution
3.4.8. Word splitting
3.4.9. File name expansion
3.5. Aliases
3.5.1. What are aliases?
3.5.2. Creating and removing aliases
3.6. More Bash options
3.6.1. Displaying options
3.6.2. Changing options
3.7. Summary
3.8. Exercises
4. Regular expressions
4.1. Regular expressions
4.1.1. What are regular expressions?
4.1.2. Regular expression metacharacters
4.1.3. Basic versus extended regular expressions
4.2. Examples using grep
4.2.1. What is grep?
4.2.2. Grep and regular expressions
4.3. Pattern matching using Bash features
4.3.1. Character ranges
4.3.2. Character classes
4.4. Summary
4.5. Exercises
5. The GNU sed stream editor
5.1. Introduction
5.1.1. What is sed?
5.1.2. sed commands
5.2. Interactive editing
5.2.1. Printing lines containing a pattern
5.2.2. Deleting lines of input containing a pattern
5.2.3. Ranges of lines
5.2.4. Find and replace with sed
5.3. Non-interactive editing
5.3.1. Reading sed commands from a file
5.3.2. Writing output files
5.4. Summary
5.5. Exercises
6. The GNU awk programming language
6.1. Getting started with gawk
6.1.1. What is gawk?
6.1.2. Gawk commands
6.2. The print program
6.2.1. Printing selected fields
6.2.2. Formatting fields
6.2.3. The print command and regular expressions
6.2.4. Special patterns
6.2.5. Gawk scripts
6.3. Gawk variables
6.3.1. The input field separator
6.3.2. The output separators
6.3.3. The number of records
6.3.4. User defined variables
6.3.5. More examples
6.3.6. The printf program
6.4. Summary
6.5. Exercises
7. Conditional statements
7.1. Introduction to if
7.1.1. General
7.1.2. Simple applications of if
7.2. More advanced if usage
7.2.1. if/then/else constructs
7.2.2. if/then/elif/else constructs
7.2.3. Nested if statements
7.2.4. Boolean operations
7.2.5. Using case statements
7.2.6. Using the exit statement and if
7.3. Summary
7.4. Exercises
8. Writing interactive scripts
8.1. Displaying user messages
8.1.1. Interactive or not?
8.1.2. Using the echo built-in command
8.2. Catching user input
8.2.1. Using the read built-in command
8.2.2. Prompting for user input
8.2.3. Redirection and file descriptors
8.2.4. File input and output
8.3. Summary
8.4. Exercises
9. Repetitive tasks
9.1. The for loop
9.1.1. How does it work?
9.1.2. Examples
9.2. The while loop
9.2.1. What is it?
9.2.2. Examples
9.3. The until loop
9.3.1. What is it?
9.3.2. Example
9.4. I/0 redirection and loops
9.4.1. Input redirection
9.4.2. Output redirection
9.5. Break and continue
9.5.1. The break built-in
9.5.2. The continue built-in
9.5.3. Examples
9.6. Making menus with the select built-in
9.6.1. General
9.6.2. Submenus
9.7. The shift built-in
9.7.1. What does it do?
9.7.2. Examples
9.8. Summary
9.9. Exercises
10. More on variables
10.1. Types of variables
10.1.1. General assignment of values
10.1.2. Using the declare built-in
10.1.3. Constants
10.2. Array variables
10.2.1. Creating arrays
10.2.2. Dereferencing the variables in an array
10.2.3. Deleting array variables
10.2.4. Examples of arrays
10.3. Operations on variables
10.3.1. Arithmetic on variables
10.3.2. Length of a variable
10.3.3. Transformations of variables
10.4. Summary
10.5. Exercises
11. Functions
11.1. Introduction
11.1.1. What are functions?
11.1.2. Function syntax
11.1.3. Positional parameters in functions
11.1.4. Displaying functions
11.1.5. Examples of functions in scripts
11.2. Summary
11.3. Exercises
12. Catching signals
12.1. Signals
12.1.1. Introduction
12.1.2. Usage of signals with kill
12.2. Traps
12.2.1. General
12.2.2. How Bash interprets traps
12.2.3. More examples
12.3. Summary
12.4. Exercises
A. Shell Features
A.1. Common features
A.2. Differing features
B. GNU Free Documentation License
B.1. Preamble
B.2. Applicability and definitions
B.3. Verbatim copying
B.4. Copying in quantity
B.5. Modifications
B.6. Combining documents
B.7. Collections of documents
B.8. Aggregation with independent works
B.9. Translation
B.10. Termination
B.11. Future revisions of this license
B.12. How to use this License for your documents
Glossary

/ Linux Reviews / Beginners: Learn Linux / Bash Guide for Beginners


Meet new people

Adult Dating