8.复制/etc目录下所有以p开头,以非数字结尾的文件或目录到/tmp/mytest1目录中。
8.复制/etc目录下所有以p开头,以非数字结尾的文件或目录到/tmp/mytest1目录中。
关键命令:cp -r /etc/p*[^[:digit:]] /tmp/mytest1
范例:
[15:06:46 root@CentOS7 ~]#ls /etc/p*[^[:digit:]] -ld
drwxr-xr-x. 2 root root 4096 Apr 4 19:44 /etc/pam.d
-rw-r--r--. 1 root root 68 Oct 1 2020 /etc/papersize
-rw-r--r--. 1 root root 2329 Apr 4 19:44 /etc/passwd
-rw-r--r--. 1 root root 2329 Apr 4 19:44 /etc/passwd-
-rw-r--r--. 1 root root 1362 Jun 10 2014 /etc/pbm2ppa.conf
-rw-r--r--. 1 root root 2872 Jun 10 2014 /etc/pinforc
drwxr-xr-x. 12 root root 151 Apr 4 19:39 /etc/pki
drwxr-xr-x. 2 root root 28 Apr 4 19:38 /etc/plymouth
drwxr-xr-x. 5 root root 52 Apr 4 19:34 /etc/pm
-rw-r--r--. 1 root root 6300 Jun 10 2014 /etc/pnm2ppa.conf
drwxr-xr-x. 2 root root 6 Jun 10 2014 /etc/popt.d
drwxr-xr-x. 2 root root 154 Apr 4 19:39 /etc/postfix
drwxr-xr-x. 3 root root 219 Apr 4 19:36 /etc/ppp
drwxr-xr-x. 2 root root 105 Apr 4 19:37 /etc/prelink.conf.d
-rw-r--r--. 1 root root 233 Jun 7 2013 /etc/printcap
-rw-r--r--. 1 root root 1819 Apr 1 2020 /etc/profile
drwxr-xr-x. 2 root root 4096 Apr 4 19:54 /etc/profile.d
-rw-r--r--. 1 root root 6545 Apr 1 2020 /etc/protocols
drwxr-xr-x. 2 root root 79 Apr 4 19:37 /etc/pulse
drwxr-xr-x. 2 root root 23 Apr 4 19:38 /etc/purple
drwxr-xr-x. 2 root root 35 Apr 4 19:35 /etc/python
[15:07:24 root@CentOS7 ~]#cp -r /etc/p*[^[:digit:]] /tmp/mytest1
cp: target ‘/tmp/mytest1’ is not a directory
[15:08:40 root@CentOS7 ~]#mkdir /tmp/mytest1
[15:09:10 root@CentOS7 ~]#cp -r /etc/p*[^[:digit:]] /tmp/mytest1
[15:09:30 root@CentOS7 ~]#ll /tmp/mytest1/
drwxr-xr-x. 2 root root 4096 Apr 5 15:09 pam.d
-rw-r--r--. 1 root root 68 Apr 5 15:09 papersize
-rw-r--r--. 1 root root 2329 Apr 5 15:09 passwd
-rw-r--r--. 1 root root 2329 Apr 5 15:09 passwd-
-rw-r--r--. 1 root root 1362 Apr 5 15:09 pbm2ppa.conf
-rw-r--r--. 1 root root 2872 Apr 5 15:09 pinforc
drwxr-xr-x. 12 root root 151 Apr 5 15:09 pki
drwxr-xr-x. 2 root root 28 Apr 5 15:09 plymouth
drwxr-xr-x. 5 root root 52 Apr 5 15:09 pm
-rw-r--r--. 1 root root 6300 Apr 5 15:09 pnm2ppa.conf
drwxr-xr-x. 2 root root 6 Apr 5 15:09 popt.d
drwxr-xr-x. 2 root root 154 Apr 5 15:09 postfix
drwxr-xr-x. 3 root root 219 Apr 5 15:09 ppp
drwxr-xr-x. 2 root root 105 Apr 5 15:09 prelink.conf.d
-rw-r--r--. 1 root root 233 Apr 5 15:09 printcap
-rw-r--r--. 1 root root 1819 Apr 5 15:09 profile
drwxr-xr-x. 2 root root 4096 Apr 5 15:09 profile.d
-rw-r--r--. 1 root root 6545 Apr 5 15:09 protocols
drwxr-xr-x. 2 root root 79 Apr 5 15:09 pulse
drwxr-xr-x. 2 root root 23 Apr 5 15:09 purple
drwxr-xr-x. 2 root root 35 Apr 5 15:09 python