linux的通配符有哪些,Linux通配符

Linux通配符

说明:通配符是bash的内置功能,几乎适用于所有Linux命令。

* 匹配任意(0个或多个)字符或字符串,包括空字符串。

? 匹配任意1个字符,有且只有一个字符。

[abcd] 匹配abcd中任何一个字符,abcd也可以是其他任意不连续字符。

[a-z] 匹配a到z之间的任意一个字符,字符前后要连续,也可以用连续数字,即[1-9]。

[!abcd] 表示不匹配括号里面的任何一个字符,也可以写为 [!a-d],这里的 "!"号可以用"^" 替代,即[^abcd]

通配符"*" 示例:

[root@testdb62 test]# touch exec.sh liang.log guo.log liang.sql a.sql

[root@testdb62 test]# ls

a.sql exec.sh guo.log liang.log liang.sql

查看所有结尾为 log 结尾的文件

[root@testdb62 test]# ls *.log

guo.log liang.log

查看所有结尾为 sh 结尾的文件

[root@testdb62 test]# ls *.sh

exec.sh

通配符"?" 示例:

[root@testdb62 test]# ls ?.sh

ls: 无法访问?.sh: 没有那个文件或目录

[root@testdb62 test]# touch a.sh

[root@testdb62 test]# ls ?.sh

a.sh

[root@testdb62 test]# ls ???.sh

ls: 无法访问???.sh: 没有那个文件或目录

[root@testdb62 test]# ls ???.log

guo.log

通配符"[abcd]" 示例:

[root@testdb62 test]# ls [abcd].sh

a.sh

[root@testdb62 test]# ls gu[opq].log

guo.log

通配符"[a-z]" 示例:

[root@testdb62 test]# touch c.sh d.sh cd.sh

[root@testdb62 test]# ls

a.sh cd.sh c.sh d.sh exec.sh guo.log liang.log liang.sql

[root@testdb62 test]# ls [a-z].sh

a.sh c.sh d.sh

[root@testdb62 test]# ls [a-z]???.sh

exec.sh

[root@testdb62 test]# touch 1

[root@testdb62 test]# touch 2

[root@testdb62 test]# ls [1-9]

1 2

通配符"[!abcd]" 示例:

[root@testdb62 test]# touch a b c d e f

[root@testdb62 test]# ls [^abcd]

1 2 e f

[root@testdb62 test]# ls

1 2 a a.sh b c cd.sh c.sh d d.sh e exec.sh f guo.log liang.log liang.sql

[root@testdb62 test]# ls [!abcd]

1 2 e f

[root@testdb62 test]# ls [!a-d]

1 2 e f

[root@testdb62 test]# ls [^1-9]

a b c d e f

标签:log,通配符,sh,ls,Linux,test,testdb62,root

来源: https://www.cnblogs.com/liang545621/p/14097794.html

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值