Shell语言-30-通配符

1.介绍

字符含义实例
*匹配0个或多个任意字符 a*b a与b之间可以存在0或多个字符ab aabb azsb …
?匹配一个任意字符 a?b,a与b之间必须但也只能存在一个字符,该字符可以是任意字符。例如:aab,abb,acb…
[list]匹配list中的任意单个字符 a[xyz]b,a与b之间必须但也只能存在一个字符,该字符只能是x或y或z。例如:axb,ayb,azb
[!list]匹配除list中的任意单个字符 a[!a-z]b,a与b之间必须但也只能存在一个字符,该字符不能是小写字母。例如:aAb,a0b…
[c1-c2]匹配c1-c2间的任意单个字符 a[0-1]b,a与b之间必须但也只能存在一个字符,该字符只能是数字。例如:a0b,a1b…
{string1,string2,…}匹配string1、string2等中的一个字符串 a{abc,xyz,opq}b,a与b之间必须但也只能存在一个字符串,字符串只能是abc或xyz或opq。例如:aabcb,axyzb,aopqb…

2. 案列

[root@Centos-root473791 ~]# ls /etc/*.conf
/etc/asound.conf                /etc/gai.conf          /etc/libaudit.conf   /etc/oddjobd.conf                  /etc/sos.conf
/etc/autofs_ldap_auth.conf      /etc/grub.conf         /etc/libuser.conf    /etc/pm-utils-hd-apm-restore.conf  /etc/sudo.conf
/etc/cas.conf                   /etc/gssapi_mech.conf  /etc/logrotate.conf  /etc/prelink.conf                  /etc/sudo-ldap.conf
/etc/cgconfig.conf              /etc/host.conf         /etc/ltrace.conf     /etc/readahead.conf                /etc/sysctl.conf
/etc/cgrules.conf               /etc/idmapd.conf       /etc/mke2fs.conf     /etc/request-key.conf              /etc/Trolltech.conf
/etc/cgsnapshot_blacklist.conf  /etc/kdump.conf        /etc/nfsmount.conf   /etc/resolv.conf                   /etc/updatedb.conf
/etc/dracut.conf                /etc/krb5.conf         /etc/nsswitch.conf   /etc/rsyslog.conf                  /etc/warnquota.conf
/etc/elinks.conf                /etc/latrace.conf      /etc/ntp.conf        /etc/sestatus.conf                 /etc/yp.conf
/etc/fprintd.conf               /etc/ld.so.conf        /etc/numad.conf      /etc/smartd.conf                   /etc/yum.conf
[root@Centos-root473791 ~]# ls /etc/???.conf
/etc/cas.conf  /etc/gai.conf  /etc/ntp.conf  /etc/sos.conf  /etc/yum.conf
[root@Centos-root473791 ~]# touch file{1,2,3}
[root@Centos-root473791 ~]# ls file*
file1  file2  file3
[root@Centos-root473791 ~]# ls file[123]
file1  file2  file3
[root@Centos-root473791 ~]# 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Alan0517

感谢您的鼓励与支持!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值