Bash Shell Scripting/Index of Symbols

Logically negates the exit status of a pipeline. For example, if  returns , then   returns  , but is otherwise equivalent. Also supported by the   builtin, and inside conditional expressions. For example, if  is true, then   is false. Also supported in arithmetic expressions. For example, if  is nonzero, then   is  . See also   below.

Quotes an argument (or part of an argument) so that it is not split by whitespace into multiple arguments, but without preventing parameter expansion and command substitution internally. See also  below. 

<ul><li>Introduces a comment (which continues to the end of the line). For example, the command  is equivalent to the command , because the comment   is removed.</li> <li>Inside an arithmetic expression, an integer literal of the form   is interpreted in base. For example,  is binary 110110, i.e. fifty-four.</li> <li>See also   below.</li> <li>See also   below.</ul>

<ul><li>(Typically "shebang" when read aloud.) Used at the very beginning of an executable script to specify the interpreter that should be used to run it. For example, if the first line of  is , and   has executable permissions, then   is roughly equivalent to  .</li> <li>The first line of a Bash script is generally either   or. (The former is generally considered preferable.)</li></ul>

<ul><li>Introduces various types of expansions, notably parameter expansion (as in  or  ), command substitution (as in  ), and arithmetic expansion (as in  ).</li></ul>

<ul><li>A variant of  (see above) that supports locale-specific translation. (Unless you're writing scripts for use in multiple languages, e.g. both English and French, you don't need to worry about this.)</li></ul>

<ul><li>The number of positional parameters (arguments to a script or function). For example, if a script is invoked as, then   will be. Builtins that modify positional parameters, such as  and , affect   as well.</li></ul>

The modulus operator. Returns the remainder resulting from integer division. E.g. 5%2 = 1

Ampersand. Commonly used to start a command in the background. E.g. Firefox &

Single quote. Used to quote text literally.

Open parenthesis. Used to denote the beginning of a subshell, among other things.

Closing parenthesis. Used to denote the "EOF" of a subshell.

Asterisk. Denotes multiplication. E.g. 5*2 = 10

Plus. Denotes addition. E.g. 5+2 = 7

Comma. Used for separation. E.g. ls file{1,2,3}

Hyphen. Denotes subtraction. E.g. 5-2 = 3

Full Stop.

Forward slash. Denotes integer division (e.g. 5/2=2) or part of a path (e.g. /home/user)

Colon.

Semicolon. Separates lines if no newline/EOL exists. E.g. echo hello; echo world

Open angle bracket. Used for input redirection

Equality sign. Used to assign variables and check equality

Closing angle bracket. Used for output redirection.

Question Mark.

At sign. Typically used as a variable containing all arguments passed to the environment as $@

Open square bracket. Used as a more visually appealing alternative to test. E.g. if [ condition ] ; then etc

Backslash. Most commonly used for escaping. E.g. rm file\ with\ a\ bunch\ of\ spaces.txt

Closing square bracket. Closes test enclosures

Caret.

Underscore.

<ul><li>Triggers command substitution; equivalent to, but is somewhat more error-prone.</li></ul>

Open curly brace. Used for specific variable expansion. E.g. (where var = "hello ") echo "${var}world" will print "hello world", echo "$varworld" will generate an error, expecting a variable called varworld.

Pipe. Used for redirecting input to output. Specifically, it takes the output of the command on the left hand side, runs the program on the right side, and then passes the contents of the first command's output to the second, as if it were being typed from a keyboard. 'ls -l | grep Desk' is equivalent to running "grep Desk", and then manually typing what ls -l would have output. Every press of the return key would then trigger grep until ^D is pressed to pass the EOF.

Closing curly brace.

Tilde. Typically used to refer to the home directory. Logged in as "mrwhite", cd ~ (or just cd) would go to /home/mrwhite. Logged in as another user, the same effect could be achieved with 'cd ~mrwhite'.