習題
顯示/var目錄下所有以l開頭,以一個小寫字母結尾,且中間至少出現一位數字(可以有其它字符)的文件或目錄。
[root@localhost /]# ls -d /var/l*[0-9]*[[:lower:]]
顯示/etc目錄下,以任意一個數字開頭,且以非數字結尾的文件或目錄。
[root@localhost /]# ls -d /etc/[0-9]*[^0-9]
顯示/etc目錄下,以非字母開頭,后面跟了一個字母以及其它任意長度任意字符的文件或目錄。
[root@localhost /]# ls -d /etc/[^[:alpha:]]*[[:alpha:]]*
在/tmp目錄下創建以tfile開頭,后跟當前日期和時間的文件,文件名形如:tfile-2016-05-27-09-32-22。
[root@localhost /]# mkdir tfile-$(date +%Y-%m-%d-%H-%M-%S)
復制/etc目錄下所有以p開頭,以非數字結尾的文件或目錄到/tmp/mytest1目錄中。
root@localhost /]# cp -r /etc/p*[^0-9] /tmp/mytest1/
復制/etc目錄下所有以.d結尾的文件或目錄至/tmp/mytest2目錄中。
[root@localhost /]# cp -r /etc/*.d /tmp/mytest2/
復制/etc/目錄下所有以l或m或n開頭,以.conf結尾的文件至/tmp/mytest3目錄中。
root@localhost /]# cp -r /etc/[l,n,b]*.conf /tmp/mytest3
原創文章,作者:N24_xiaowen,如若轉載,請注明出處:http://www.www58058.com/57764
幾個練習題總結的不錯~排版也不錯~加油~