Special characters used in bash scripts or command lines
1. # Well number: Comment
In Echo, # cannot be annotated.
Some specific pattern matching operations can also be used #,
2.; semicolon: Command separator. Two or more commands can be written on the same line using the command separator.
3.; double semicolon: Used to terminate the case option
4. Point Number:
"Point" command, equivalent to the source command
"Point" is part of the file name. If it is placed at the beginning of the file name, the file will become a "hidden" file.
"Point" character matching. When used as a matching character, it is usually used as part of a regular expression. "point" is used to match any single character.
5. "Double quotation marks: Partially referenced." string "will block (interpreted) most of the special characters in string.
6. 'single quotes: All references. 'string' will block all special characters in the string.
7. Comma: comma operator. The comma operator links a series of arithmetic operations. Although all the content is run, only the last one is returned.
8. \ backslash: Escape Character
9./slash: delimiter of the file name path. It can also be used as a Division arithmetic operator.
10. ': Command replacement. The 'command' structure can assign the command output value to a variable.
11. Colon: Empty command, equivalent to "NOP", can also be considered to be the same as the built-in shell command true
It can be used in the while endless loop, while:
Placeholder in IF/then, if xxx; then:; else xxx
Provide a placeholder in a binary command: $ {username = 'whoamam'}. If ":" Is not started, an error is prompted, unless "username" is a command or built-in command
Provide a placeholder for the command in here document
Use parameter replacement to evaluate the string variable: $ {hostname ?} $ {User ?} $ {Mail ?}, If one or more necessary environment variables are not set, the error message is printed.
When used with the> Redirection operator, a file is cleared, but the permission of the file is not modified. if this file does not exist before, create the file (:> data. xxx # file "data. XXX "is cleared now)
It can also be used as separators in the/etc/passwd and $ PATH variables.
12 ,! Exclamation point: gets the inverse operator, which will reverse the result of the exit code of the command, and reverse the meaning of the test operator.
13. * asterisks:
Used as a wildcard for file name matching
It can also be used in regular expressions to match any number of characters (including 0 ).
Arithmetic Operator, multiplication operation. If it is a power operator, use **
14 ,? Question mark:
Test operator, used to test the results of a condition in a specific expression.
In a Double Bracket structure ,? Similar to the ternary operator in C language [(t = A <45? ))]
In the parameter replacement expression, it is used to test whether a variable is set.
It can be used as a wildcard to match a single character. In a regular expression, it is also used to represent a character.
15. $:
16. $ {}: parameter replacement
17. $ *, [email protected]: Location Parameter
18, $? : Exit status code variable, a command, a function, or exit status code of the script itself
19. $: process ID variable, saving the process ID of the script
20. () parentheses: Command Group, [(test = Xixi; echo $ test)]. The command list in parentheses will be run as a sub-shell, the parent shell cannot read the variables created in the subshell.
21. () Double parentheses: This is an integer expression used to expand and calculate in ().
22. braces:
{
Echo "Haha"
Echo "ARCHIVE listing :"
}> $ File
{Read line1
Read line2
} <$ File
A command may take effect on the comma-separated file list in braces. mkdir {Haha, XiXi}. Note: blank spaces are not allowed in braces unless the blank space is referenced or escaped.
Braces and commands are enclosed to form a code block. In fact, an anonymous function is created. Unlike the standard function, the Code of other parts of the script must be visible (that is, the local keyword cannot be used)
Code block and I/O redirection: read multiple data from one file to multiple variables
You can also save the results of a code block to a file.
23, {}\;: Identify the path name, which is generally used in the find command. ";" is the-exec option used to end the sequence of the find command.
24. [] brackets:
It can be a conditional test command, or a shell built-in command.
In the context of an array structure, brackets are used to reference the numbers of each element in the array.
It can be used as part of a regular expression. Square brackets describe a matching character range.
25. [[] Double brackets: Also a conditional test command
26. >>>>>><>: redirect
27. (command)>, <(command): Process replacement
28. <: Redirection used in the here document
29. <: used for redirection in here string
30, \ <, \>: The word boundary in the regular expression, grep '\ <What \> 'textfile
31. |: pipe., analyze the output of the Front Command, and use the output as the input of the back command
32,> |: Force redirect
33. |: logical or
34. &: logical and
35. &: If the command is followed by an &, the command is run in the background. In the script, both the command and the loop can be run in the background (note: in a script, running the command (&) in the background may cause the script to be suspended until you press enter to recover the suspended script, this problem occurs only when the result of this command needs to be output to stdout)
36 ,-:
Option prefix
Used to redirect stdin or stdout [(CD/data/directory & tar CF-.) | (CD/DEST/directory & tar xpvf -)]
Indicates the last working directory
Used for arithmetic operation minus signs
37, +, =, %: Arithmetic Operator
38 ,~,~ + ,~ -: Home Directory, current working directory, previous working directory
39, = ~ : Regular Expression matching used in the double brackets test expression. [["$ variable" = ~ "T * fin * es *"]
----- Refer to advanced bash Script Programming Guide
This article comes from "logic, pursuit !" Blog, please be sure to keep this source http://hjh524.blog.51cto.com/4248253/1565097
Bash special characters