Special characters
# Note
- Comment # comment
- In the middle of the quotation mark and # representation # itself
- Echo $ {path # * :}# parameter replacement, not a comment
- Echo $(2 #101011) # Number conversion, not a comment
; Separator
- Command separation, write multiple commands in one line echo "AA"; echo "BB"
- If the IF and then conditions are placed in the same row, they are also separated;
; End of the case condition
The. Command is equivalent to the source command.
- Command: Source
- The prefix of the file name to hide the file.
- Directory:. Current Directory,... parent directory
- Regular Expression: matches any single character
"" Some references support wildcard Extension
''Full reference, without wildcard Extension
\ Escape
/Directory Separator
Multiple commands are executed, but the last one is returned.
'Post reference
: Operator
- Null operation
- Endless loop: while:
- In if/then, it indicates that nothing is done.
- Set the default parameter: $ {username = 'whoamam '}
- Variable replacement: $ {hostname ?} $ {User ?} $ {Mail ?}
- When used in combination with the> (redirection operator), a file is truncated to 0 length without modifying its permissions. If the file does not exist before, it is created. for example:> data. xxx # file "data. XXX "is cleared now. and CAT/dev/null> data. xxx works the same. However, this does not produce a new process, because ":" is a built-in command. when used with the> Redirection operator, it will not affect the file to be appended. if the file does not exist, it is created.
* Matches 0 or multiple characters. It is a mathematical multiplication. ** it is a power operation.
? Match any character, but in (A> B? A: B) indicates the Three-Objective Operation in C.
$
- Echo $ path
- Indicates the end of a row in a regular expression.
- $ {} Parameter replacement $ {paht}
- $ * All Parameters
- $ # Number of parameters
- $ Process ID
- $? Process return status
()
- Command Group, run in a sub-shell (A = 3; echo $ A) where the Defined variables are not available later
- Array initialization: array = (a, B, c)
{} Code block, which is an anonymous function, but the Defined variables are still available later
{}\; Used in find-exec $ find-name *. txt-exec cat {}\;
[]
- Test [-Z $1]
- Array Element A [1] = 'test'
- [[] Indicates test use[[...]Condition judgment structure, instead[...]To prevent many logical errors in the script. for example, the &, |, <, and> operator can normally exist in the [[] condition judgment structure, but if it appears in the [] structure, an error is returned.
- () Mathematical operations
- In a regular expression, the value range is [A-Z].
<> Rewrite and process replacement LS-Al> a.txt
> <Also used to compare if ["$ veg1" <"$ veg2"] with ASCII
\<,\> The word boundary in the regular expression. for example, bash $ grep '\ <The \> 'textfile | pipeline> | force redirect (even if the noclobber option is set-C ). this will forcibly overwrite an existing file. | logic or operation; when used between two commands, it indicates that when the previous command ends, if the returned value is false, continue to execute the next command & logical and; when used between two commands, it indicates that if the return value is true at the end of the previous command, continue to execute the next command & run in the background-
- Parameter options
- Minus sign
- Redirect stdin and stdout: CD/source/directory & tar CF-.) | (CD/DEST/directory & tar xpvf -)
- Previous working directory CD-
- Note: there may be some problems with file names and variable names starting "-".
+
Mark the options of a command or filter .~ Home directory ~ + Current working directory ~ -In the previous working directory ^ regular expression, $ ifs at the beginning of the line is used to separate some input commands. By default, it is blank.
Control characters
Modify terminal or text display behavior .. control characters are combined by Control + key (simultaneously press ). the control characters can also be expressed in octal or hexadecimal notation, but the front must be added with an escape character.
The control characters cannot be used normally in the script.
CTL-B Return (non-destructive), that is, return but do not delete the previous character.
CTL-C ends a foreground job.
CTL-D logs out of a shell (similar to exit ).
"EOF" (end of file). This can also terminate input from stdin.
When entered in the console or in the xterm window, CTL-D will delete the characters under the cursor. when no characters exist, CTL-D will exit the current session. In an xterm window, the window will be closed.
CTL-G beep. On some vintage typewriter terminals, it will ring.
CTL-h "return" (destructive) is to delete the character of the front edge after the return.
CTL-I horizontal tab.
CTL-J ). in the script, you can also use the octal notation-'\ 012' or the hexadecimal notation-' \ x0a.
CTL-K vertical tab.
CTL-l clear screen (clear the screen display of the terminal ). in the terminal, the effect is the same as that of the clear command. when it is sent to the printer, CTL-l will let the printer roll the print paper to the end.
CTL-M press Enter.
CTL-Q recovery (Xon). Recover stdin in one terminal.
CTL-s pending (xoff ).
Freeze stdin in a terminal. (use CTL-Q to restore the input .)
CTL-u deletes all characters from the cursor to the beginning of the line. In some settings, CTL-u deletes the entire line of input regardless of the position of the cursor.
When CTL-V is entered, CTL-V allows the insertion of control characters.
CTL-V is mainly used for text editing.
CTL-W
When you type text in the console or an xterm window, CTL-W deletes all characters between the current cursor and the nearest space on the left. in some settings, CTL-W deletes all characters from the current cursor to the first non-letter or number on the left.
CTL-Z pause foreground job.
Reference: Advanced bash Script Programming Guide