cp重点在于复制,主要将一个或多个源文件或者文件夹复制到指定的目的文件或文件夹(可以理解为在window系统上操作,根据自己所需复制文件或文件夹粘贴到指定位置)
cp = copy
cp -r /folder1 /folder2
[root@iZbp1d8rn0652ia3bzzmioZ local]# cd test1/
[root@iZbp1d8rn0652ia3bzzmioZ test1]# ls -l
总用量 0
-rw-r--r-- 1 root root 0 11月 23 23:00 111111.txt
-rw-r--r-- 1 root root 0 11月 23 23:00 1111.txt
-rw-r--r-- 1 root root 0 11月 23 22:59 111.txt
[root@iZ test1]# cd ../test2/
[root@iZ test2]# ls
[root@iZ test2]# cp -r /usr/local/test1/ /usr/local/test2/
[root@iZ test2]# ls
test1
[root@iZ test2]# cd test1/
[root@iZ test1]# ls
111111.txt 1111.txt 111.txt
[root@iZ test1]#
cp -r /folder1/* /folder2
drwxr-xr-x 2 root root 55 11月 23 23:00 test1
drwxr-xr-x 2 root root 6 11月 23 23:07 test2
[root@iZ local]# cd test1/
[root@iZ test1]# ls
111111.txt 1111.txt 111.txt
[root@iZ test1]# cd ../test2/
[root@iZ test2]# ls
[root@iZ test2]# cp /usr/local/test1/* /usr/local/test2
[root@iZ test2]# ls
111111.txt 1111.txt 111.txt
[root@iZ test2]#
cp -i /folder1/xxx.txt /folder2
[root@iZ test2]# ls
111111.txt 1111.txt 111.txt
[root@iZ test2]# cd ../test1/
[root@iZ test1]# ls
111111.txt 1111.txt 111.txt
[root@iZ test1]# cp -i 111.txt /usr/local/test2
cp:是否覆盖'/usr/local/test2/111.txt'? y
[root@iZ test1]#
cp -a 1111.txt /usr/local/test2/
[root@iZ test1]# ls -l
总用量 0
-rw-r--r-- 1 root root 0 11月 23 23:00 111111.txt
-rw-r--r-- 1 root root 0 11月 23 23:00 1111.txt
-rw-r--r-- 1 root root 0 11月 23 22:59 111.txt
[root@iZ test1]# cp 111.txt /usr/local/test2/
[root@iZ test1]# cd /usr/local/test2/
[root@iZ test2]# ls -l
总用量 0
-rw-r--r-- 1 root root 0 11月 23 23:28 111.txt
[root@iZ test1]# ls -l
总用量 0
-rw-r--r-- 1 root root 0 11月 23 23:00 111111.txt
-rw-r--r-- 1 root root 0 11月 23 23:00 1111.txt
-rw-r--r-- 1 root root 0 11月 23 22:59 111.txt
[root@iZ test1]# cp -a 1111.txt /usr/local/test2/
[root@iZ test1]# cd /usr/local/test2/
[root@iZ test2]# ls -l
总用量 0
-rw-r--r-- 1 root root 0 11月 23 23:00 1111.txt
-rw-r--r-- 1 root root 0 11月 23 23:28 111.txt
好了,今天的学习就到这里!欢迎大家评论区参与交流与讨论,更好的学习与进步!
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。