Special character Encyclopedia in Bash
By expanding, the character you enter will expand into another character before the shell works on it. Such as:
[Sl@sl ~]$ Echo *
Desktop Pic Txt.save
The shell expands the name of the file under the current working directory before the Echo command is executed.
Path name Expansion
The working mechanism that wildcards rely on is called the path name expansion.
echo * Current directory all non-hidden files
Echo. * current directory All files with.
ls-d. * | less ls-d.
[!.]? *
Wavy Line Expansion
Wavy line characters ("~") have special meanings. When it is used at the beginning of a word, it expands to the home directory name of the specified user and, if no user name is specified, expands to the home directory of the current user.
[Sl@sl ~]$ echo ~
/HOME/SL
an arithmetic expression expands
Format: $ ((expression))
Echo $ ((2 + 2))
4
echo $ ((5**2) * 3))
75
Curly Braces Expand
The curly brace expression itself contains a list of strings separated by commas, or a series of integers, or a single string. This mode cannot embed whitespace characters.
echo front-{a,b,c}-back
front-a-back front-b-back front-c-back
Echo number_{1..5}
number_1 number_ 2 number_3 number_4 number_5
echo {Z. A}
Z Y X W V U T S R Q P O N M L K J I H G F E D C B A
echo a{a{1,2},b{3,4}}b
aa1b aa2b ab3b ab4b
mkdir {2007..2009}-0{1..9} {2007..2009}-{10..12}
parameter Expansion
$ variable invocation symbol
Usage: $ variable
Mechanism: Call variable to get ' value of variable '
Echo $USER
command Substitution
Linux command substitution and redirection are somewhat similar, but the difference is that the command substitution is the output of one command as a parameter of another Linux command
echo $ (LS)
Desktop Documents ls-output.txt Music Pictures public Templates Videos can
also use inverted quotes instead of $ ()
ls-l ' which CP '
-rwxr-xr-x 1 root 71516 2007-12-05 08:5 8/bin/cp
Word Segmentation
By default, the word segmentation mechanism looks for spaces, tabs, and line breaks in a word, and sees them as the defining character between words. This means that no referenced spaces, tabs, and newline characters are part of the text and are used only as delimiters.
The echo this are a test this is
a test
Reference
The shell provides a mechanism called a reference to selectively prohibit unwanted expansion.
"" Double quote
It contains the content as a normal character, but $,\ (backslash), and ' (inverted quotes).
This means that Word segmentation, path name expansion, wavy line expansion, and braces expansion will fail, but the parameter expansion, arithmetic expansion, and command substitution are still valid.
"Single quote
Take what it contains as a normal character, without exception
echo text ~/*.txt {a,b} $ (echo foo) $ ((2+2)) $USER
text/home/me/ls-output.txt a b foo 4 SL
The wavy line expands in double quotes, the path name expands, the curly braces are expanded, the parameters expand, the arithmetic expands, and the command substitution is still valid.
Echo ' text ~/*.txt {a,b} $ (echo foo) $ ((2+2)) $USER '
text ~/*.txt {a,b} foo 4 me
Fail all in single quotation marks
Echo ' text ~/*.txt {a,b} $ (echo foo) $ ((2+2)) $USER '
text ~/*.txt {a,b} $ (echo foo) $ ((2+2)) $USER
Escape Character
character preceded by a backslash \