03-2017-11-09-练习-glob

练习1-glob

1、 显示/var目录下所有一1开头,一一个小写字母结果,且中间至少出现一个数字的目录和文件

[root@centos6 dirtest]# ls -d /var/1*[0-9]*[[:lower:]]

2、 显示/etc目录下,一非字母开头,后面跟一个字母,以及其他任意长度字符的文件或者目录

[root@centos6 dirtest]# ls -d /etc/[^[:alpha:]][[:alpha:]]*

3、复制/etc/目录下,所有以m开头,以非数字结尾的文件或者目录到/tmp/magedu目录

[root@centos6 dirtest]# cp /etc/m*[^0-9] /tmp/magedu

4、复制/etc目录下,所有以.d结尾的文件或者目录到/tmp/magedu.com目录中

[root@centos6 dirtest]# cp /etc/*.d /tmp/magedu.com

5、复制/etc目录下,所有以.conf结果,且一m,n,r,p开头的文件或者目录到/tmp/magedu.com目录中

[root@centos6 dirtest]# cp /etc/[mnrp]*.conf /tmp/magedu

练习2-glob

1 、显示/var 目录下所有以l 开头,以一个小写字母结尾,且中间出现至少一位数字的文件或目录

[root@centos7 glob]# ls -d /var/l*[0-9]*[[:lower:]]

2 、显示/etc 目录下以任意一位数字开头,且以非数字结尾的文件或目录

[root@centos7 glob]# ls /etc/[0-9]*[^0-9]

3 、显示/etc/ 目录下以非字母开头,后面跟了一个字母及其它任意长度任意字符的文件或目录

[root@centos7 glob]# ls -d /etc/[^[:alpha:]][[:alpha:]]*

4 、显示/etc/ 目录下所有以rc 开头,并后面是0-6 之间的数字,其它为任意字符的文件或目录

[root@centos7 glob]# ls -d /etc/rc[0-6]*

5 、显示/etc 目录下,所有以.d 结尾的文件或目录

[root@centos7 glob]# ls -d /etc/*.d

``` 6 、显示/etc 目录下,所有.conf 结尾,且以m,n,r,p 开头的文件或目录

[root@centos7 glob]# ls -d /etc/[mnrp]*.conf

7 、只显示/root 下的隐藏文件和目录

[root@centos7 glob]# ls -ad /root/.*

8 、只显示/etc下的非隐藏文件

ls /etc/[^.]* -d