Linux中的cp命令
2015-08-20 08:30
471 查看
cp命令用来复制文件或者目录
命令格式:
cp [选项] ... 源 ..... 目的
命令功能:
将源文件复制到目标文件,或者将多个源文件复制到目标目录
命令实例:
(1)
复制单个文件到目标目录,文件在目标目录中不存在
(2)目标文件存在的时候,会询问是否覆盖
(3)复制整个目录
(4)建立一个连接档(相当于windows的快捷方式)
命令格式:
cp [选项] ... 源 ..... 目的
命令功能:
将源文件复制到目标文件,或者将多个源文件复制到目标目录
命令实例:
(1)
复制单个文件到目标目录,文件在目标目录中不存在
[root@centos65 testorder]# ll total 4 drwxr-xr-x 4 root root 31 Aug 19 09:54 test001 -rw-r--r-- 1 root root 18 Aug 19 09:58 test003.log -rw-r--r-- 1 root root 0 Aug 19 09:57 test003.log~ [root@centos65 testorder]# [root@centos65 testorder]# [root@centos65 testorder]# cp test003.log test001 [root@centos65 testorder]# [root@centos65 testorder]# [root@centos65 testorder]# ll total 4 drwxr-xr-x 4 root root 49 Aug 20 08:36 test001 -rw-r--r-- 1 root root 18 Aug 19 09:58 test003.log -rw-r--r-- 1 root root 0 Aug 19 09:57 test003.log~ [root@centos65 testorder]# [root@centos65 testorder]# [root@centos65 testorder]# [root@centos65 testorder]# cd test001 [root@centos65 test001]# ll total 4 drwxr-xr-x 2 root root 6 Aug 19 09:55 test drwxr-xr-x 2 root root 78 Aug 19 09:55 test001 -rw-r--r-- 1 root root 18 Aug 20 08:36 test003.log
(2)目标文件存在的时候,会询问是否覆盖
[root@centos65 testorder]# cd test001 [root@centos65 test001]# ll total 4 drwxr-xr-x 2 root root 6 Aug 19 09:55 test drwxr-xr-x 2 root root 78 Aug 19 09:55 test001 -rw-r--r-- 1 root root 18 Aug 20 08:36 test003.log [root@centos65 test001]# [root@centos65 test001]# cp test003.log test001 cp: overwrite `test001/test003.log'? y
(3)复制整个目录
[root@centos65 test001]# ll total 4 drwxr-xr-x 2 root root 6 Aug 19 09:55 test drwxr-xr-x 2 root root 78 Aug 19 09:55 test001 -rw-r--r-- 1 root root 18 Aug 20 08:36 test003.log [root@centos65 test001]# [root@centos65 test001]# [root@centos65 test001]# [root@centos65 test001]# cp -a test001 test [root@centos65 test001]# [root@centos65 test001]# [root@centos65 test001]# cd test [root@centos65 test]# ll total 0 drwxr-xr-x 2 root root 78 Aug 19 09:55 test001 [root@centos65 test]# cd ../test001 [root@centos65 test001]# ll total 8 -rw-r--r-- 1 root root 40 Aug 19 09:24 test001.log -rw-r--r-- 1 root root 0 Aug 19 09:36 test002.log -rw-r--r-- 1 root root 18 Aug 20 08:37 test003.log -rw-r--r-- 1 root root 0 Aug 19 09:36 test004.log
(4)建立一个连接档(相当于windows的快捷方式)
[root@centos65 test]# ll total 8 drwxr-xr-x 2 root root 78 Aug 19 09:55 test001 -rw-r--r-- 1 root root 40 Aug 20 08:47 test001.log drwxr-xr-x 2 root root 6 Aug 20 08:43 test002 -rw-r--r-- 1 root root 0 Aug 20 08:47 test002.log -rw-r--r-- 1 root root 18 Aug 20 08:47 test003.log -rw-r--r-- 1 root root 0 Aug 20 08:47 test004.log [root@centos65 test]# [root@centos65 test]# [root@centos65 test]# cp -s test001.log test001_link.log [root@centos65 test]# ll total 8 drwxr-xr-x 2 root root 78 Aug 19 09:55 test001 lrwxrwxrwx 1 root root 11 Aug 20 08:50 test001_link.log -> test001.log -rw-r--r-- 1 root root 40 Aug 20 08:47 test001.log drwxr-xr-x 2 root root 6 Aug 20 08:43 test002 -rw-r--r-- 1 root root 0 Aug 20 08:47 test002.log -rw-r--r-- 1 root root 18 Aug 20 08:47 test003.log -rw-r--r-- 1 root root 0 Aug 20 08:47 test004.log
相关文章推荐
- linux文件上传下载笔记(rz,sz,sftp,scp)命令
- linux 信号详解
- Linux下查看在线用户及用户进程
- Linux下查看在线用户
- linux多线程编程详解
- centos安装devtoolset-3支持gcc 4.9.2
- Centos配置国内yum源
- centos --- phpunit 安装过程
- CENTOS linux kernel 内核编译
- linux下mysql的root密码忘记解决
- Centos 6.5 下php5.6.2 的编译安装说明
- linux配置网卡
- linux 连接wlan
- Linux记录
- FHS-date
- Linux下gdb使用入门
- CentOS6.5 安装php(5.3.3)扩展 mcrypt
- 给linux添加yum源。
- 这么奇怪的bug已经很久不见了
- 深入理解Linux内存管理