首页 > 代码库 > linux学习命令总结⑥
linux学习命令总结⑥
#文件名通配
通配符:
*:匹配任意长度的任意字符(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
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。