|NO.Z.00041|——————————|LinuxShell|——|Linux&Shell$特殊符号.V01|——|通配符|单引号|双引号|反引号|小括号|中括号|大括号|

一、shell的通配符:通配符
  作用
匹配一个任意字符
* 匹配0个或任意多个任意字符,也就是可以匹配任何内容
[] 匹配中括号中任意一个字符,
例如:[abc]代表一定匹配一个字符,或者是a或者是b,或者是c
[-] 匹配中括号中任意一个字符,-代表一个范围,例如:[a-z]代表匹配一个小写字母
[^] 逻辑非,表示匹配不是中括号的一个字符,
例如:[^0-9]代表匹配一个不是数字的字符
二、shell通配符实验
### --- 建立几个测试文件

[root@localhost tmp]#   touch       abc
[root@localhost tmp]#   touch       abcd
[root@localhost tmp]#   touch       012
[root@localhost tmp]#   touch       0abc
### --- “*”代表所有的文件

[root@localhost tmp]# ls *
012 0abc abc abcd
### --- “?”匹配任意一个字符,所以会匹配 0abc
### --- 但是不能匹配 abc,因为“?”不能匹配空

[root@localhost tmp]# ls ?abc
0abc
### --- 匹配任何以数字开头的文件

[root@localhost tmp]# ls [0-9]*
012 0abc
### --- 匹配不已数字开头的文件

[root@localhost tmp]# ls [^0-9]*
abc abcd

 

 

 

 

 

 

 

 

 

 
 

Walter Savage Landor:strove with none,for none was worth my strife.Nature I loved and, next to Nature, Art:I warm'd both hands before the fire of life.It sinks, and I am ready to depart
                                                                                                                                                   ——W.S.Landor

 

posted on 2022-03-26 23:18  yanqi_vip  阅读(35)  评论(0)    收藏  举报

导航