Bash Shell Scripting/Index of Symbols
Appearance
Symbol | Explanation |
---|---|
! |
|
"…" |
|
# |
|
#! |
|
$ |
|
$"…" |
|
$# |
|
% | 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. |
`…` |
|
{ | 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'. |