|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   yanqi_vip  阅读(26)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· DeepSeek 开源周回顾「GitHub 热点速览」
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示