[Top level Bash Page] .... [References]

Shells, Command Lines, Variables, Init files, and Pipelines


This page introduces the Unix shell, some material applies generally to any Unix shell, other material might be specific to Bash.

The following material comes from many of the references however references [3-5] are likely the most relevant.

Terminology and definitions:

Definitions/Terms:

Special characters and words

The following is a brief explanation of how the shell works (see ch 3 or ref 3).

 

 

Variables -

 

Shell expansion is performed after each command line has been split into tokens. More specifically, variables undergo any of the following expansions

Built in Commands

 

 

Patterns

There three kinds of pattern matching in Bash : globs, extended globs, and regular expressions. Bash does not support regex however utilities, filters, commands use regex (e.g., sed, awk, grep).

 

Glob Patterns (refer to this chapter in the Advanced Bash Scripting Guide)

Globs are composed of normal characters and metacharacters. Metacharacters are characters that have a special meaning. These are the metacharacters that can be used in globs:


*: Matches any string, including the null string.
?: Matches any single character.
[...]: Matches any one of the enclosed characters.

 

Extended Globs


Bash also supports a feature called Extended Globs. They are similar to regular expressions. Extended globs are disabled by default and we will try to avoid them in our scripts.

 

Regular Expressions

Regular expressions (regex) are similar to Glob Patterns, but they can only be used for pattern matching, not for filename matching. We will pay particular attention to the use of regex in the following situations:

 

Refer to this page for more details on regular expressions.



Last update: 4/29/2018