|
Metacharacters (as explained by the shell) |
|
`` |
command in exchange for command execution results |
[[email protected] ~]# ls
4.txt anaconda-ks.cfg a.txt B.txt c.txt D.txt nginx-1.10.3 nginx-1.10.3.tar.gz
[[email protected] ~]# res= ' ls ' #取命令的运行结果, assign to variable res
[Email protected] ~]# echo $res #查看变量res的值
4.txt anaconda-ks.cfg a.txt B.txt c.txt D.txt nginx-1.10.3 nginx-1.10.3.tar.gz |
|
$ |
$ variable Value |
[Email protected] ~]# money=10
[Email protected] ~]# echo $money
10
[Email protected] ~]# echo 00000$money
0000010
[Email protected] ~]# echo $money 0000
[Email protected] ~]# echo ${money}0000
100000
$[] integer calculation echo $[2+3]-*/% floating point with echo "scale=3; 10/3 "| Bc-l |
|
${} |
Range of variable names |
|
|
$() |
With ', but it makes up for ' nesting flaws |
[Email protected] ~]# res= ' echo ' ls ' #嵌套使用后无法达到预想的效果: Take the effect of the Echo pile file name.
[Email protected] ~]# echo $res
Ls
[Email protected] ~]# res=$ (echo $ (LS)) #替代方案
[Email protected] ~]# echo $res
4.txt anaconda-ks.cfg a.txt B.txt c.txt D.txt nginx-1.10.3 nginx-1.10.3.tar.gz |
|
~ |
Home Directory |
[Email protected] tmp]# CD ~
[Email protected] ~]# pwd
/root |
|
! |
Take Non- |
[Email protected] ~]# LS/DEV/SDA
SDA SDA1 Sda2
[[email protected] ~]# ls/dev/sda[0123]
/dev/sda1/dev/sda2
[[email protected] ~]# ls/dev/sda[!01]
/dev/sda2 |
|
History command Invocation |
[Email protected] ~]#!343
Hostname
Miwifi-r3-srv |
|
Match last History command |
[Email protected] ~]#!ls
LS/DEV/SDA[!01]
/dev/sda2 |
|
! LS with a space to reverse the return value of the command |
[[email protected] ~]# echo OK
Ok
[[email protected] ~]# echo $? #上一条命令执行的结果, 0 for execution success, not 0 for execution failure
0
[[email protected] ~]#! echo OK #将结果取反
Ok
[[email protected] ~]# echo $?
1
0-255, 0 is true, not 0-bit false |
|
@ |
No special meaning |
|
|
# |
# Notes |
|
|
% |
Kill the background process, the jobs number; Take the mold |
|
|
^ |
Take the non-and! Identical |
[[email protected] ~]# ls/dev/sda[^01]
/dev/sda2
[[email protected] ~]# ls/dev/sda[!01]
/dev/sda2 |
|
Replace |
[Email protected] ~]# systemctl Restart Network
[Email protected] ~]# ^network^sshd^
Systemctl Restart sshd |
|
& |
Background execution |
|
|
&& |
Logic and |
|
|
* |
Match any length string; compute multiplication |
|
|
() |
Executing in a child process |
[Email protected] ~]# x=1
[Email protected] ~]# (x=666)
[Email protected] ~]# echo $x
1
[Email protected] ~]#
[Email protected] ~]# (X=666;echo $x)
666 |
|
- |
A minus sign; an interval; CD- |
|
|
_ |
No special meaning |
|
|
+ |
Plus |
|
|
= |
Assign value |
|
|
| |
Pipeline |
|
|
|| |
Logical OR |
|
|
\ |
Translated |
[[email protected] test]# echo \ \
\
[[email protected] test]# echo \ '
‘
[[email protected] test]# echo "'"
‘ |
|
{} |
Command list, note that the beginning and end of parentheses must be a space {ls; } |
|
|
[] |
Word wildcard match, matching one of the parentheses inside |
|
|
: |
: null Command truth |
[Email protected] ~]#:
[[email protected] ~]# echo $?
0 |
|
; |
Multiple commands can be received: Ls;pwd;echo 123; Whether right or wrong, will continue to the last command |
|
|
“” |
"" soft-quoted characters in quotes make sense |
[Email protected] test]# x=1
[[email protected] test]# echo "$x" #双引号的代表软引用, special characters in quotation marks have special meanings, such as $, ' etc.
1
[[email protected] test]# echo ' $x ' #单引号代表硬引用, all characters in quotes have no special meaning
$x |
|
’‘ |
' Hard cited, all characters in quotation marks have no special meaning |
|
< |
< input redirection |
|
|
> |
> Output redirection |
|
|
>> |
>> Append |
|
|
<< |
<< here Document |
|
|
>& |
>& merging 2 and 1 outputs |
|
|
, |
, enumerate separators |
|
|
. Source |
. source; Current directory |
|
|
/ |
/directory Separators |
|
|
? |
? Single character |
|
|
? Wildcard characters: any character |
|
|
Enter |
Enter command execution |
|
|
* |
* Wildcard characters: any character |
|
|
One of the [ABC] list items |
|
|
[^ABC] can also use the range [A-z] for the list to represent the aabbcc...,[0-9] for the 012345 ... |
|
|
{} |
{} Loop List |
[[email protected] test]# Touch {1..3}{a ... D}.txt
[[email protected] test]# ls
1a.txt 1b.txt 1c.txt 1d.txt 2a.txt 2b.txt 2c.txt 2d.txt 3a.txt 3b.txt 3c.txt 3d.txt |
|
Range of control variable names echo ${ab}c |
|