Characters used with commands
- Character
- Usage
- |
- Pipes the output from one command to a second command; separates commands in a pipeline.
- ||
- Separates two commands. If the command preceding || fails, it runs the following command (Boolean OR operator).
- >
- Redirects stdout.
- <
- Redirects stdin.
- &
- Runs a command in the background, if placed at the end of a command line.
- >&
- Used for redirecting stdout and stderr.
- &&
- Separates two commands. If the command preceding && succeeds, it runs the following command (Boolean AND operator).
- ;
- Separates sequential commands; allows you to enter more than one command on the same line.
- ( )
- Around a sequence of commands, groups those commands that are
to run as a separate process in a subshell environment. The commands
run in a separate execution environment: changes to variables, the
working directory, open files, and so on, will not remain in effect
after the last command finishes.
(␠) is also used to group mathematical operations.
- { }
- Around a sequence of commands, groups those commands that are
run in the current shell environment. Changes to variables will affect
the current shell.
Both { and } are reserved words to the shell. To make it possible for the shell to recognize these symbols, you must enter a blank or <newline> after the {, and a semicolon or <newline> before the }.
- #
- Following a command in a shell script, indicates the beginning of a comment.
- $
- At the beginning of a string, indicates that it is a variable name.
- \
- In general, the backslash character turns off the special meaning of the character that follows it. For more information, see Using a special character without its special meaning.
- ' '
- A pair of single quotation marks turns off the special meaning of all characters within the quotation marks. For more information, see Using a special character without its special meaning.
- " "
- A pair of double quotation marks turns off the special meaning of the characters within the quotation marks, except that !event, $var, and `cmd` will show history, variable, and command substitution. See Using a special character without its special meaning for more information.