Characters
Last updated
Last updated
Char. | Description |
---|---|
~
(tilde). The path to a user's home directory location.
-
(hyphen). Go to the previously chosen directory.
└─>
Option flag for a command or filter.
└─>
Arithmetic operator. Minus of arithmetic operations.
/
Root directory [forward slash]. The path to root directory location.
└─>
Filename path separator.
\
Escape [backslash]. A quoting mechanism for single characters. It preserves the literal value of the next character that follows, with the exception of newline.
└─>
Arithmetic operator. Divider of arithmetic operations.
|
Pipe. This is a method of chaining commands together. Connects the output (stdout) of command1 to the input (stdin) of command2. Each command reads the previous command’s output.
|&
This operator connects the output (stdout) and error (stderr) of command1 to the input (stdin) of command2.
||
The OR operator is used to chain commands. It will execute the first command then stop if successful, if not, it will proceed pass failed commands until one is successful and stop.
&&
The AND operator is used to chain commands. It will execute commands only if the first command is successful and proceed until one fails.
;
Command separator [semicolon]. Used to separate multiple commands and output all successful and failed ones.
&
Run job in background [and]. A command followed by an & will run in the background.
>, >>, <
Redirect a command's standard output (stdout) or input (stdin) into a file.
&>, >&
Redirects a command's both standard output (stdout) and error (stderr) into a file.
<&-
Close standard input (stdin) to prevent showing from a file.
>&-
Close standard output (stdout) to prevent showing from a file.
>|
Force redirection (even if the noclobber option is set). This will forcibly overwrite an existing file.
"
Partial quoting [double quotes]. Protects the text inside them from being split into multiple words or arguments, yet allow substitutions to occur, meaning most other special characters is usually prevented.
.
Source command [period]. To evaluate commands in the current execution context. This is a bash builtin.
└─>
"As a component of a filename. When working with filenames, a leading dot is the prefix of a "hidden" file, a file that an ls will not normally show.
└─>
Character match. When matching characters, as part of a regular expression, a "dot" matches a single character.
'
Full quoting [single quotes]. Protects the text inside them so that it has a literal meaning. This is a stronger form of quoting than double quotes.
`
Command substitution [backquotes]. Assign the output of a shell command to a variable.
#
Comment [number sign]. Lines in files beginning with a # (with the exception of #!) are comments and will not be executed.
!
Reverse (or negate) [exclamation]. The ! operator inverts the exit status of the command to which it is applied. It also inverts the meaning of a test operator.
*
Wild card [asterisk]. The * character serves as a "wild card" for filename expansion in globbing By itself, it matches every filename in a given directory.
└─>
Arithmetic operator. Multiplier of arithmetic operations.
?
Wild card [question mark]. The ? character serves as a single-character "wild card" for filename expansion in globbing, as well as representing one character in an extended regular expression.
└─>
Test operator. Within certain expressions, the ? indicates a test for a condition.
{ }
Inline group [curly brackets]. Commands inside the curly braces are treated as if they were one command.
└─>
Placeholder for output text.
( )
Subshell group [parentheses]. Commands within are executed in a subshell (a new process) Used much like a sandbox, if a command causes side effects (like changing variables), it will have no effect on the current shell.
[ ]
Test expression [brackets]. It is part of the shell builtin test.
└─>
Array element. Brackets set off the numbering of each element.
└─>
Range of characters. As part of a regular expression, brackets delineate a range of characters to match.
[[ ]]
Test/Evaluate [double brackets] a condition expression to determine whether true or false. It is more flexible than the single-bracket [ ] test.
(( ))
Arithmetic expression [double parentheses]. Characters such as +, -, *, and / are mathematical operators used for calculations.
~+
Current working directory.
~-
Previous working directory.
:
Null command [colon]. This is the shell equivalent of a "NOP" (no op, a do-nothing operation). It may be considered a synonym for the shell builtin true.
;;
Terminator [double semicolon]. Only used in case constructs to indicate the end of an alternative.
" "
Whitespace. This is a tab, newline, vertical tab, form feed, carriage return, or space. Bash uses whitespace to determine where words begin and end.
,, ,
Lowercase conversion in parameter substitution.
^, ^^
Uppercase conversion in parameter substitution.
$
Variable substitution. A $ prefixing a variable name indicates the value the variable holds
└─>
End-of-line. In a regular expression, a "$" addresses the end of a line of text.
$*
All the arguments are seen as a single word.
!!
The previous command.
!$
The last argument to the previous command.
!*
All the arguments from the previous command.
$?
The exit status of the last command executed.
$#
The number of arguments supplied to a script.
$$
The process number of the current shell. For shell scripts, this is the process ID under which they are executing.
$!
The process number of the last background command.
$_
Special variable set to final argument of previous command executed.
$-
Expands to the current option flags as specified upon invocation, by the set builtin command, or those set by the shell itself (such as the -i option).
$0
Used to reference the name of the current shell or current shell script.
$n
These variables correspond to the arguments with which a script was invoked. Here n is a positive decimal number corresponding to the position of an argument (the first argument is $1, the second argument is $2, and so on).