码迷,mamicode.com
首页 > 系统相关 > 详细

linux学习命令总结⑥

时间:2014-08-12 13:52:34      阅读:385      评论:0      收藏:0      [点我收藏+]

标签:cccccc   linux   通配符   style   

#文件名通配

通配符:

*:匹配任意长度的任意字符(0到多个)

[root@VM_168_102_centos ~]# ls *
0812080808

2014-05-16:
test.log

ceshi_1:

test:
[root@VM_168_102_centos ~]# ls -ld t*
drwxr-xr-x 2 root wanghan 4096 Aug 11 15:46 test

?:匹配任意单个字符

[root@VM_168_102_centos ~]# ls
0812080808  2014-05-16  ceshi_1  test
[root@VM_168_102_centos ~]# ls tes?
[root@VM_168_102_centos ~]# ls -ld tes? 
drwxr-xr-x 2 root wanghan 4096 Aug 11 15:46 test
[root@VM_168_102_centos ~]# ls -ld t?st
drwxr-xr-x 2 root wanghan 4096 Aug 11 15:46 test
[root@VM_168_102_centos ~]# ls -ld t???
drwxr-xr-x 2 root wanghan 4096 Aug 11 15:46 test
[root@VM_168_102_centos ~]# ls -ld t?? 
ls: cannot access t??: No such file or directory

[ ]:匹配指定字符范围内的任意单个字符

[root@VM_168_102_centos ~]# ls -ld *[abc]
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 abc
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 xab
[root@VM_168_102_centos ~]# ls -ld *[ac]
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 abc
[root@VM_168_102_centos ~]# ls -ld [abc]*
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 abc
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 abd
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 abe

[a-z]:所有小写字母

[root@VM_168_102_centos ~]# ls
ABC  abc  abd  abe  xab
[root@VM_168_102_centos ~]# ls -ld *[a-z]
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 abc
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 abd
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 abe
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 xab

[[:lower:]]:所有小写字母

[root@VM_168_102_centos ~]# ls -ld *[[:lower:]]
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 abc
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 abd
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 abe
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 xab

[A-Z]:所有大写字母

[root@VM_168_102_centos ~]# ls
ABC  abc  abd  abe  xab
[root@VM_168_102_centos ~]# ls -ld *[A-Z]
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 ABC

[[:upper:]]:所有大写字母

[root@VM_168_102_centos ~]# ls -ld *[[:upper:]]
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 ABC

[[:alpha:]]:所有字母,不区分大小写

[root@VM_168_102_centos ~]# ls -ld *[[:alpha:]]
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 ABC
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 abc
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 abd
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 abe
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 xab

[0-9]:所有数字

[root@VM_168_102_centos ~]# ls
123  ABC  abc  abd  abe  xab
[root@VM_168_102_centos ~]# ls -ld *[0-9]
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:50 123
[root@VM_168_102_centos ~]# ls -ld *[23]
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:50 123

[[digit:]]:所有数字

[root@VM_168_102_centos ~]# ls -ld *[[:digit:]]
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:50 123

[[:alnum:]]:所有数字和字母,字母不分大小写

[root@VM_168_102_centos ~]# ls -ld *[[:alnum:]]
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:50 123
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 ABC
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 abc
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 abd
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 abe
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 xab

[[:space:]]:空格

[root@VM_168_102_centos ~]# ls
123  ABC  a c  abc  abd  abe  xab
[root@VM_168_102_centos ~]# ls -ld *[[:space:]]
ls: cannot access *[[:space:]]: No such file or directory
[root@VM_168_102_centos ~]# ls -ld *[[:space:]]*
drwxr-xr-x 2 root wanghan 4096 Aug 12 11:13 a c

[[:punct:]]:标点符号

[root@VM_168_102_centos ~]# ls
,,1  123  ABC  a c  abc  abd  abe  xab
[root@VM_168_102_centos ~]# ls -ld [[:punct:]]*
drwxr-xr-x 2 root wanghan 4096 Aug 12 11:16 ,,1

[^]:匹配指定字符范围外的任意单个字符

[^0-9]:除了数字

[root@VM_168_102_centos ~]# ls
,,1  123  ABC  a c  abc  abd  abe  xab
[root@VM_168_102_centos ~]# ls -ld *[^0-9]
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 ABC
drwxr-xr-x 2 root wanghan 4096 Aug 12 11:13 a c
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 abc
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 abd
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 abe
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 xab

[^[:upper:]]:除了大写字母

[root@VM_168_102_centos ~]# ls -ld *[^[:upper:]]
drwxr-xr-x 2 root wanghan 4096 Aug 12 11:16 ,,1
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:50 123
drwxr-xr-x 2 root wanghan 4096 Aug 12 11:13 a c
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 abc
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 abd
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 abe
drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 xab

linux学习命令总结⑥,布布扣,bubuko.com

linux学习命令总结⑥

标签:cccccc   linux   通配符   style   

原文地址:http://putongren.blog.51cto.com/9086263/1538937

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!